If You Are From The 09 Batch Then Read This >>

This Site is created for the Bharati Vidyapeeth's BCA 09 Batch..and hence everyone from you are requested to send your email ID at abhilash238650@gmail.com..Owner will send you a request to your Email-ID and after accepting it even you can post your views, day to day experiences and class works on this blog.
Visit owner's blog at
www.bloggerabhilash.info
Showing posts with label Assignments. Show all posts
Showing posts with label Assignments. Show all posts

Thursday, April 21, 2011

Visual Basic Practicals

Practical 1 : Listbox and Combo Box

Private Sub Command1_Click()
List1.AddItem Text1.Text
Text1.SetFocus
Command1.Enabled = False
Label1.Caption = List1.ListCount
End Sub

Private Sub Command2_Click()
Dim Remove As Integer
Remove = List1.ListIndex
List1.RemoveItem Remove
Label1.Caption = List1.ListCount
End Sub

Private Sub Command3_Click()
List1.Clear
Label1.Caption = List1.ListCount
End Sub

Private Sub Text1_Change()
If (Len(Text1.Text) > 0) Then
Command1.Enabled = True
End If
End Sub



Horizontal Scroll Bar

Private Sub Command1_Click()
Dim I As Integer
Dim J As Integer
I = 1
Do While I < HScroll1.Value
J = J + I
I = I + 1
Loop
Text1.Text = Str(J)
End Sub

Check Box and Option button Font and Color

Private Sub chkBold_Click()
If chkBold.Value = 1 Then
Text1.FontBold = True
Else
Text1.FontBold = False
End If
End Sub

Private Sub chkitalic_Click()
If chkitalic.Value = 1 Then
Text1.FontItalic = True
Else
Text1.FontItalic = False
End If
End Sub

Private Sub chkunderline_Click()
If chkunderline.Value = 1 Then
Text1.FontUnderline = True
Else
Text1.FontUnderline = False
End If
End Sub

Private Sub optblue_Click()
Text1.ForeColor = vbBlue
End Sub

Private Sub optgreen_Click()
Text1.ForeColor = vbGreen
End Sub

Private Sub optred_Click()
Text1.ForeColor = vbRed
End Sub

 Timer Control

Practical no. 5 : TIMER CONTROL

set timer at enable=false interval=250

Start a new VB project and put 2 command buttons and a timer control on the form. set the properties of the controls as follows:
Command button - property - Name: cmdStart Caption: start timer

Command button - name: cmdStop Caption: StopTimer

Timer: Name: tmr Test Enabled:False Interval:250

In General declaration:
Private mintcount as integer

Code the click event for the 2 command button and the timer event for the timer control as follows:
Private sub cmdstart_click()
mint count=0
timer1. enable =true
end sub

Private sub cmdstop_click()
timer1.enable=false
end sub

Private sub Timer1_timer()
mint count+1
Print "timer fine origin count =" & mint count
end sub

Shipment Cost: Checkbox and option button

Private Sub CmdCalcost_Click()
Dim unitorder As Integer
Dim cost As Currency
unitorder = Val(txtbox1.Text)
If optWholesaler.Value = 1 Then
Select Case unitorder
Case 1 To 15
cost = unitorder * 50
Case 16 To 20
cost = unitorder * 45
Case 21 To 30
cost = unitorder * 40
Case 31 To 50
cost = unitorder * 35
Case Is > 50
cost = unitorder * 30
End Select
Else
Select Case unitorder
Case 1 To 15
cost = unitorder * 60
Case 16 To 20
cost = unitorder * 55
Case 21 To 30
cost = unitorder * 50
Case 31 To 50
cost = unitorder * 45
Case Is > 50
cost = unitorder * 40
End Select
End If

If chkdisc1.Value = 1 Then
cost = cost - (cost * 0.1)
End If
TextBox2.Text = cost
End Sub

Traffic Signal



Design an application to display traffic lights. All lights for 9 secs and yellow for 5 secs.

1. start VB & create a new project
2. Save the form & project as frmtraffic.frm
3. set the caption of your form as 'Traffic Light'
4. Now create the controls & place them according to the screenshot shows above.
You can draw the desired shape by setting the shape property. set the shape property to 3-circle to obtain circles.
5. also name the controls as labelled in the screenshots.
6. now set the properties of 3 inner circles as follows:
Name                      Property                        Setting
shpRed                Backcolor                       VbRed
                           Backstyle                       1-opaque
shpYellow            same as above                VbWhite
shpGreen             same as above                vbWhite
tmrlights                Enabled                         True


7. Go to the code view: type option explicit at the top of the code page. as declare the variable state as shown below.
Dim state as integer

8. Now double click the event for change(cmdchange) button :

Private sub cmdchange_click()
state=1
shpRed.backcolor=VbRed
shpyellow.backcolor=Vbwhite
shpgreen.backcolor=VbWhite
label1.caption="stop"
Timer1.enable=true
End Sub

Create the timer event for timer tmrlights
now double click the timer and write the following code:

Private Sub Timer1_Timer()
If state=3
   state=1
Else
state=state+1
End If
Select state
Case1
ShpRed.back color=VbRed
ShpYellow.back color=VbWhite
ShpGreen.back color=VbWhite
Label1.caption="Stop"
Timer1.Interval=250

Case2
ShpRed.backcolor=Vbwhite
ShpYellow.backcolor=Vbyellow
ShpGreen.backcolor=Vbwhite
label1.caption="wait"
Timer1.Interval=250

Case3
ShpRed.backcolor=VbWhite
ShpYellow.backcolor=VbWhite
ShpGreen.backcolor=VbGreen
label1.caption="Go"
Timer.Interval=250
End Select
End Sub


ADODC through coding

Public conn As ADODB.Connection
Public rs As ADODB.Recordset

Private Sub Command1_Click()
rs.MoveFirst
End Sub

Private Sub Command2_Click()
rs.MovePrevious
If rs.BOF Then
    rs.MoveLast
End If

End Sub

Private Sub Command3_Click()
rs.MoveNext
If rs.EOF Then
    rs.MoveFirst
End If
End Sub

Private Sub Command5_Click()
rs.AddNew
End Sub

Private Sub Command6_Click()
rs.Update
End Sub

Private Sub Command7_Click()
rs.Delete
rs.Update
End Sub

Private Sub Form_Load()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\ADMIN\My Documents\employee.mdb;Persist Security Info=False"
conn.Open
Set rs = New ADODB.Recordset
rs.Open "emp", conn, adOpenStatic, adLockOptimistic, adCmdTable

Set Text1.DataSource = rs
Text1.DataField = "empno"

Set Text2.DataSource = rs
Text2.DataField = "job"

Set Text3.DataSource = rs
Text3.DataField = "salary"

Set Text4.DataSource = rs
Text4.DataField = "empname"

Set Text5.DataSource = rs
Text5.DataField = "deptno"

Set Text6.DataSource = rs
Text6.DataField = "manager"

Set MSHFlexGrid1.DataSource = rs

End Sub

DAO through coding

Private Sub Command1_Click()
Data1.Recordset.MoveFirst
End Sub

Private Sub Command2_Click()
Data1.Recordset.MovePrevious
If Data1.Recordset.BOF = True Then
    Data1.Recordset.MoveLast
End If
End Sub

Private Sub Command3_Click()
Data1.Recordset.MoveNext
If Data1.Recordset.EOF = True Then
    Data1.Recordset.MoveFirst
End If
End Sub

Private Sub Command4_Click()
Data1.Recordset.MoveLast
End Sub

Private Sub Command5_Click()
Data1.Recordset.AddNew
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = True
Command7.Enabled = False
End Sub

Private Sub Command6_Click()
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command7.Enabled = True
If (MsgBox("do u want to save data", vbYesNo) = vbYes) Then
Data1.Recordset.Update
End If
End Sub

Private Sub Command7_Click()
Data1.Recordset.Delete
Data1.Recordset.MoveNext
End Sub

Wednesday, December 22, 2010

Program 21 to 24 !!!



21.write a programe for operator == for string

#include
#include
Class Prashant
{
char name[20];
int flag;
void getdata()
{
cout<<"Enter the Name";
cin>>name;
}
int operator==(prashant s)
{
flag=stremp(name,s.name);
return flag;
}
};
void main()
{
clrscr()
prashant s.t;
s.getdata();
t.getdata();
int x=(t==s);
y=(x==0)
cout<<"String are Equal";
else
cout<<"Not Equal";
getch();
}


22.Write a programe to demonstrate multiple hierasehical inheretense
a.accept deposit
b.display balance
c.compute & deposite interupt
4.permit withdrawl and update balance




#include
#include

Class account
{
public:
       char name[25];
       char type of[25];
       int amt,bal,withdraw,deposit;
     
account()
{
bal=500;
}
void getdata()
{
cout<<"Enter the name,a/c number and the type of ";
cin>>name>>accno>>typeof;
}
};
class current:public account
{
public:
void getdeposit()
{
cout<<"Enter the Deposit amt\n";
cin>>deposit;
bal=bal+deposit;
}
void withdrawamt()
{
cout<<"Enter the amt to withdraw\n";
cin>>withdraw;
}
void penalty()
}
if(bal<500)
bal=bal-50;
}
void display()
{
cout<<"Name\t"<<<<\n Accounttype\t",,typeof<<"\nBalance"<
}
};
class using:public account
{
float interest;
public;
void getdeposit()
{
cout<<"\nEnter the deposit amount\n";
cin>>deposit;
bal=bal+deposit;
}
void cal instrest()
{
int n=3;float r=7.5;
intrest=(bal*n*r)/100;
bal=bal+intrest;
}
void withdraw amt()
{
cout<<"Enter the amt to withdraw \n";
cin>>withdraw:
bal=bal-withdraw;
}
void penelty()
{
if(bal<500)
bal=bal-50;
}
void display()
{
cout<<"Name \t"<<<"\n Account \t"<<<"\naccount type\t"type of <<"\n balance "<<<
}
};
void main()
{
clrscr();
current a;
a.getdata();
a.getdeposit();
a.withdrawamt();
a.penalty();
a.display();

savingb;
b.getdeposit();
b.calintrest();
b.withdrawamt();
b.penalty();
getch();
}


23.write a program to demonstrate hybride inheramtence

#include
#include

Class student
{
public:
       char name[25];
int rollno;
void getdata()
{
cout<<"Enter the name & roll no of the student";
cin>>name>>rollno;
}
};
class test:public student
{
public:
int sem1,sem2;
void getmarks()
{
cout<<"\n Enter the marks of sem1 and sem2 \n";
cin>>sem1>>sem2;
}
};
class sports
{
public:
      int sportmarks;
voidgetscore()
{
cout<<"\n Enter the marks of sports \n;
cin>>sportsmarks;
}
};
class result:public  test.public sports
{
public:
int total;
void caltotal()
{
total=sem1+sem2+sportsmark;
}
void display()
{
cout<<"\n name1+"<<<"\nRoll no+"<<<"\ntotalmarks+"<
}
};
void main()
{
char();
resilts;
s.getdata();
s.getmarks();
s.getscore();
s.caltotal();
s.display();
getch();
}


24) WAP 2 model a database wth emp as a base class & wth the att name, id , for mgr att are titles & dues, writer attributes book labour att are wages.

    #include
    #include
   class employee
   {
   public:
   long id;
   char name[25];
   void get data()
   {
   cout<<"n\enter the name & id\n";
   cin>>name>>id;
    }
  };
   class manager:public employee
   {
   public :
   char title[30];
   long due;
   void get info ()
   {
   cout<<"\n enter the title & dues amt\n";
   cin>>title>>dues;
   }
   void display()
   {
   cout<<"\n Name\t"<<<"nid\t"<<<"\n
  title \t"<<<"\n dues\t"<
  }
};
class writer:public employee
{
public:
char books [25];
void get books()
{
cout <<"\nenter the name of  books\n";
cin>> books;
}
void display()
{
cout <<"\n Name \t"<<<"\nid\t"
<<<"\n book\t"<
  }
};
class labour :public employee
{
public:
int wages;
void get wages()
{
cout <<"enter the wages of the employee\n";
cin>>wages;
}
void display()
{
cout <<"enter the wages of the employee\n";
cin>>wages;
}
void display()
}
cout <<"\n Name \t"<<<"\nid\t"
<<<"\nwages\t"<
  }
};
void main()
{
clrscr();
manager s;
s.getdata();
s.getinfo();
s.display();
writer a;
a.getdata();
a.getbooks();
a.getdisplay();
labour b;
b.getdata();
b.getwages();
b.display();
getch();
}

Program 11 to 20 !!!

11. Create a class to calculate the marksheet with the attributes such as seat no, total marks, out of marks.

#include
#include

class result
{
long seatno;
int totalmarks;
int outofmarks;
void getdata();
void percentage();
void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a;
a.getdata();
a.percentage();
a.displaydata();
getch();
} tdio.h>
#include

class result
{
long seatno;
int totalmarks;
int outofmarks;
void getdata();
void percentage();
void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a;
a.getdata();
a.percentage();
a.displaydata();
getch();

}

 12. Create a class to calculate the marksheet with the attributes seat no, total marks, out of marks for 10 students.

#include
#include

class result
{
long seatno;
int totalmarks;
int outofmarks;
public:
    void getdata();
    void percentage();
    void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a[10];
for(i=1;i<=10;i++)
{
a[i].getdata();
a[i].percentage();
a[i].displaydata();
}
getch();
}  seatno;
int totalmarks;
int outofmarks;
public:
    void getdata();
    void percentage();
    void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a[10];
for(i=1;i<=10;i++)
{
a[i].getdata();

a[i].percentage();
a[i].displaydata();
}
getch();
}

13. to calculate the total salary using gross salary=basic + 47%DA + 30% HRA with attribute a.getdata b.calculate salary and c. show details.

#include
#include

class salary
{
float basic,HRA,DA;
float grosssalary;
public:
    void getdata();
    void calsalary();
    void display();
};

void salary::getdata()
{
cout<<"Enter the basic salary \n";
cin>>basic;
DA=47/100*basic;
cout<<
HRA=30/100*basic;
cout<
}
void salary::calsalary()
{
grosssalary=(basic+HRA=DA);
}
void salary::display()
{
cout<<
}

void main()
{
clrscr();
salary s;
s.getdata();
s.calsalary();
s.display(); 
getch();
}
#include

class salary
{
float basic,HRA,DA;
float grosssalary;
public:
    void getdata();
    void calsalary();
    void display();
};

void salary::getdata()
{
cout<<"Enter the basic salary \n";
cin>>basic;
DA=47/100*basic;
cout<<
HRA=30/100*basic;
cout<
}
void salary::calsalary()
{
grosssalary=(basic+HRA=DA);
}
void salary::display()
{
cout<<
}

void main()
{
clrscr();
salary s;
s.getdata();
s.calsalary();
s.display();

getch();
}


14. using switch statement. Create account class for following operators. 1. create account, 2.deposit, 3.withdraw. 4.bal enquiry 5.show details.

#include
#include
#include

class account
{
private:
    long int actno;
    char name[40];
    float bal;
public:
account()
{
bal=500.00;
}
void createaccount()
{
cout<<" \n Enter ACT NO AND NAME \n";
cin>>actno>>name;
cout<<"\n Account is created sucessfully \n";
}
void deposit()
{
int deposit;
cout<<" \ n Enter Amt to Deposit \n";
Cin>>deposit;
bal=bal+deposit;
}
void withdraw()
{
int wd;
cout<<" \n Enter Amt to withdraw \n";
cin>>wd;
if(bal <= 500)
  cout<<" \n Sorry! insufficient Amt \n";
else if(wd>=bal)
  cout<<" \n Sorry! insufficient Amt \n";
else
  bal=bal-wd;
}
void showdetails()
{
cout<<" \n--------------------Welcome to SBI----------------\n";
cout<<" \n A/c no.<
cout<<" \n Name"<
cout<<" \n Balance"<
cout<<" \n---------------------SBI--------------------------\n";
}
};
void main()
{
clrscr();
account a;

int op;
do{
cout<<"\n---------------------------------------------------\n";
cout<<"\n OPTION 1:- create A/c  \n";
cout<<"\n OPTION 2:- Deposit     \n";
cout<<"\n OPTION 3:- Withdrawn   \n";
cout<<"\n OPTION 4:- Bal Enquiry \n";
cout<<"\n OPTION 5:- EXIT        \n";
cout<<"\n Enter your choice      \n";
cout<<"\n---------------------------------------------------\n";
cin>>op;
switch(op)
{
case1:a.create account();break;
case2:a.deposit();break;
case3:a.withdraw();break;
case4:a.showdetails();break;
case5:exit(0);
default:cout<<"Sorry!Invalid choice";
}
}
while(op!=5);
getch();
}


15. using switch statement. create a/c class for following operators for 10 persons - create a/c, deposit, withdraw, bal enquiry, show details.

#include
#include
#include

class account
{
private:
    long int actno;
    char name[40];
    float bal;
public:
account()
{
bal=500.00;
}
void createaccount()
{
cout<<" \n Enter ACT NO AND NAME \n";
cin>>actno>>name;
cout<<"\n Account is created sucessfully \n";
}
void deposit()
{
int deposit;
cout<<" \ n Enter Amt to Deposit \n";
Cin>>deposit;
bal=bal+deposit;
}
void withdraw()
{
int wd;
cout<<" \n Enter Amt to withdraw \n";
cin>>wd;
if(bal <= 500)
  cout<<" \n Sorry! insufficient Amt \n";
else if(wd>=bal)
  cout<<" \n Sorry! insufficient Amt \n";
else
  bal=bal-wd;
}
void showdetails()
{
cout<<" \n--------------------Welcome to SBI----------------\n";
cout<<" \n A/c no.<
cout<<" \n Name"<
cout<<" \n Balance"<
cout<<" \n---------------------SBI--------------------------\n";
}
};
void main()
{
clrscr();
account a[i];

int op;
for(i=1;i<=10,i++)
{
do
{
cout<<"\n---------------------------------------------------\n";
cout<<"\n OPTION 1:- create A/c  \n";
cout<<"\n OPTION 2:- Deposit     \n";
cout<<"\n OPTION 3:- Withdrawn   \n";
cout<<"\n OPTION 4:- Bal Enquiry \n";
cout<<"\n OPTION 5:- EXIT        \n";
cout<<"\n Enter your choice      \n";
cout<<"\n---------------------------------------------------\n";
cin>>op;
switch(op)
{
case1:a[i].create account();break;
case2:a[i].deposit();break;
case3:a[i].withdraw();break;
case4:a[i].showdetails();break;
case5:exit(0);
default:cout<<"Sorry!Invalid choice";
}
}
while(op!=5);
}
getch();
} ";
cout<<"\n OPTION 2:- Deposit     \n";
cout<<"\n OPTION 3:- Withdrawn   \n";
cout<<"\n OPTION 4:- Bal Enquiry \n";
cout<<"\n OPTION 5:- EXIT        \n";
cout<<"\n Enter your choice      \n";
cout<<"\n---------------------------------------------------\n";
cin>>op;
switch(op)
{
case1:a[i].create account();break;
case2:a[i].deposit();break;
case3:a[i].withdraw();break;
case4:a[i].showdetails();break;
case5:exit(0);
default:cout<<"Sorry!Invalid choice";

}
}
while(op!=5);
getch();
}


16. to calculate area of rectangle using DEFAULT CONSTRUCTION.

a] Default constructor

#include
#include
class rectangle
{
int l,b;
float area;
public:
void rectangle()
{
l=10;
b=20;
}
void calculate()
{
area=l*b;
}
void show()
{
cout<<"area= "<
}
};
void main()
{
clrscr();
rectangle r;
r.getdata();
r.calculate();
r.show();
getch();
}

b] PARAMETERIZED Constructor

#include
#include
class rectangle
{
int l,b;
float A;
public:
rectangle(int p,int q)
{
l=p;
b=q;
}
void call()
{
a=l*b;
}
void display()
{
cout<<"\n Length & Breadth is "<<
cout<<"\n Area is "<<;
}
};
void main()
{
clrscr();
rectangle r(10,20);
r.cal();
r.display();
getch();
}


17th- Unary operator for increament

#include
#include
class unary
{
int x,y,z;
public:
void getdata();
void operator+();
void show();
};
void unary::getdata(int a,int b,int c)
{
x=a;
y=b;
z=c;
}
void unary::show
{
cout<<<
}
void main()
{
clrscr();
unary s;
s.getdata(2,3,4);
+s;
s.show();
getch();
}


18- Binary to overload + operator

#include
#include
class binary
{
float a,b;
public:
binary(float x,float y)
{
a=x;
b=y;
}
binary operator +(binary)
};
binary operator +(binary b)
{
binary p;
p.a=a+b/a;
p.b=b+b/b;
return(p);
}
void main()
{
binary c1,c2;
c1(1.2,2.3);
c2(2.0,2.1);
c3=c1+c2;
c3.show();
getch();
}


19- using(18) friend function

#include
#include
class binary
{
float a,b;
public:
binary(float x,float y)
{
a=x;
b=y;
}
void friend operator+(binary);
};
void friend operator+(binary);
{
binary p;
p.a=a+b1.a;
p.b=b+b1.b;
return(p);
}
void main()
{
binary c1,c2;
c1(1.2,2.3);
c2(2.0,2.1);
c3=c1+c2;
c3.show();
getch();
}


20 - for + operator for string

#include
#include
#include
class string
{
char *p;
int n;
public:
string(){n=0;p=0;}
string(const char *s);
string(const string &s);
friend string operator +(const string & s.cout string &t);
friend void show(const string s);
};
string::string(const char*s)
{
n=strlen(s);
p=new data[n+1];
strcpy(p,s);
}
string::string(const string &s)
{
n=s.n;
p=new char[n+1];
strcpy(p,s.p);
}
string operator+(const string &s, const string &t)
{
string temp;
temp.n=s.n+t.n;
temp.p=new char[temp.n+1];
strcpy(temp.p,s.p);
strcat(temp.p,t.p);
return(temp);
}
void show(const string s)
{
cout<
}
void main()
{
show(s1)="Bharati";
show(s2)="Vidyapeeth";
show(t3);
getch();
}

Program 1 to 10 !!!

 1. swap 2 numbers using call by value.

#include
#include

void swap (int a,int b)
{
int t;
t=a;
a=b;
b=t;

cout<<
}

void main()
{
clrscr();
void swap(int a,int b);
int x,y;
x=10;
y=15;
swap(x,y);
getch();
}



2. swap two numbers using call by reference.


#include
#include

void swap (int *a,int *b)
{
int t;
t=&a;
&a=&b;
&b=t;
}


void main()
{
clrscr();
void swap(int *a,int *b);
int x,y;
x=10;
y=15;
swap(&x,&y);
cout<<"Swapped values are"<<
getch();
}



3.inline function to calculate Area of CIRCLE 

#include
#include

inline float area(int r)
{
return(3.14*r*r);
}

void main()
{
clrscr();
int r=5;
float b;
b=area(r);
cout<
getch();


3.b. inline function for avg of 3 nos.

#include
#include

inline float avg(int a,int b,int c)
{
return((a+b+c)/3);
}

void main()
int a,b,c;
clrscr();
cout<<"Enter the nos.";
cin>>a>>b>>c;
float av=avg(a,b,c);
cout<
getch();
}


3.c. inline function for area of triangle

#include
#include

inline float area(int b,int h)
{
return(0.5*b*h);
}

void main()
{
int b,h;
clrscr();
cout<<"Enter the height and base of triangle";
cin>>b>>h;
float ar=area(b,h);
cout<
getch();
}


4. overload a function to add integer, float and double each having 2 or 3 parameters.

#include
#include

int add(int a,int b);
float add(float a,float b,float c);
double add(double x,double y);

int add(int a,int b)
{
return(a+b);
}
float add(float a,float b,float c)
{
return(a+b+c);
}
double add(double x,double y)
{
return(X+y);
}

void main()
{
clrscr();
cout<<
cout<<
cout<<
getch();
}


5. overload a function to calculate area of rectangle having different data types such as integer,float and double.

 #include
#include

int area(int l,int b);
float area(float l,float b);
double(double l,double b);

int area(int l,int b)
{
return(l*b);
}
float area(float l,float b)
{
return(l*b);
}
double area(double l,double b)
{
return(l*b);
}

void main()
{
int l,b;
clrscr();
cout<<
cout<<
cout<<
getch();
}



6. To calculate area of triangle ,rectangle and square. 


#include
#include

float triangle(float b,float h);
float rectangle(float l,float b);
float square(float s);

float triangle(float b,float h)
{
return(0.5*b*h);
}
float rectangle(float l,flaot b)
{
return(l*b);
}
float square(float s)
{
return(4*s);
}

void main()
int l,b,h,s;
clrscr();
cout<<
cout<<
cout<<
getch();



7. To find the interest with rate 1.5 using default argument 


#include
#include

float interest(int p,int n,float r=1.5)
{
return((p*n*r)/100);
}

void main()
{
clrscr();
int p,n;
cout<<"Enter principle and no.years \n";
cin>>p>>n;
float i=interest(p,n);
cout<<"interest is"<
getch();



8. to give alias name to a variable principle in calculating simple interest & then modifying the variable. 


#include
#include

float interest(int p,int n,float r)
{
return((p*n*r)/100);
}

void main()
{
clrscr();
int p,n;
int &alias=p;
float r;
cout<<"Enter the principles & no. of years \n";
cin>>p>>n>>r;
float i=interest(p,n,r);
cout<<"\n interest is before modifying \t"<
alias=20;
cout<<"\n principle is modified \t"<i=interest(p,n,r);
cout<<"\n Interest after modifying principle \t"<
getch();
}



9. Swap the 2 numbers using reference variable.


#include
#include

void swap(int &a,int &b)
{
int t;
t=a;
a=b;
b=t;
}

void main()
{
void swap(int &a,int &b);
clrscr();
int x=10;
int y=20;
cout<<"before swapping \t"<<<"   \t"<
swap(x,y);
cout<<"  \n after swapping   \t"<<<    \t"<
getch();
}



10. to take student's information from the user & display it using CLASS student. 


#include
#include

class stud
{
int rno;
char name[20];
public:
void getdata()
{
cout<<"Enter the roll no. &name \n";
cin>>rno>>name;
}
void display()
{
cout<<"\n Roll no \t"<<<" \n Nmae  \t"<
}
};

void main()
{
clrscr();
stud s;
s.getdata();
s.display();
getch();
}

Wednesday, October 27, 2010

Best in CAOS Presentation and DBD Submission !!!

            Today, Gokhila madam rocked. She gave us numbers of assignments to do. She also announced that Abhilash Ruhela and Vandana Singh gave the best presentation. I am happy as I am Abhilash Ruhela and I would like to congratulate Vandana Singh too. 


             Today itself, Sheetal mam also announced some names who gave the best work on the topics given. I was also one of them. I am happy to be in the List of Merit. I am happy that my efforts and works are being noticed. Thanks you Gokhila mam and Sheetal mam.. Both of you are at my Best Teacher's list now. ;-)

            

Sunday, October 24, 2010

Assignments - A Deadly Weapon !!!





        Again the terrible days are back. Numerous assignments in my pockets to do and less time to complete and accomplish them. I just hate these days when I have to slog a lot just to complete assignments. I don't want my routine to be affected by any means of addition in my routine. I just hate when our teachers announces a big and huge assignment to us with a wicked smile and clamor the Deadline as we are going to get the best treat of our life on this day. I just hate this. I have no problem if teacher gives us the topic in the start of the term and give us a last date at that time itself. But some teacher are so intelligent and over-professional that they don't give any trouble to students for the whole term but as they see that only 1 week is remaining and then these students are going to get a long Preparation Leave, let them strive for this 1 week. And this 1 week seems to be like the biggest hell in our life. 


            My teachers has given us number of assignments. Everyone of them know that this will be very hard for students to do in this limited period of time. I just want to ask teachers that you have seen us for 6 months and you would be knowing our participation in the class activities, why do you need to give us an assignment to judge our potential? Even if you want to judge our potential through assignments, give us a justifiable period of time to show our real power and capabilities. Do you think that a child can show all his capabilities only in 1 night through preparing that assignment? You will never get the best even from the brightest student of the class. If your retaliation is that you want to see our modus operandi and our dedication and honesty towards our work and job and you want to match our honesty with our quest to meet the deadlines then I would say that Yes, we will complete the assignments on the Deadline but will we get something to learn from this? No !!! 


          A student will try once or twice or thrice or ten times to meet the deadline but once if he or she will realize that teachers are crossing the limit of torture, they will directly reply to you on the face-to-face conversation that if you want to cut my Internal marks, you are free for this but I am not going to strive madly for completing your useless assignment. We are 18 to 20 years old. I know that we are at the period when we should be made capable of facing all the disasters in the future while working in the organization but that doesn't means that you will overload us like a donkey. And if you really want to do this then also remember that Donkey kicks too. Be ready for the Kicks. Today, I and some of my classmates gathered together to complete our journal. We are blessed with 22 or 25 programs. We didn't wasted any time and we did it as fast as it was possible but in the whole day we succeeded to complete only 13 programs out of them. And this is just 1 subject. We have other 2 to 3 subject's assignment too. Can you imagine the stress we all are going through?


            I have nothing to say except this. I am in fultoo stress and thus I created this blog post today. Teachers, please think that even we are human beings. We aren't machine that just need greasing and it runs with the same accelerated speed. We are human being and even we need a break. I have nothing much to say now. 


             Thanks.


ABHILASH RUHELA - VEERU

Just Type The Keyword To Search Your Answer -- >>