Professional Documents
Culture Documents
MANDIR
COMPUTER
SCIENCE(C++)
PRACTICAL FILE
SUBMITTED TO
SUBMITTED BY
HEMANT DIXIT
AYUSH PURI
CERTIFICATE
THIS
CLASS
12TH
AYUSH
PURI OF
(MRS.MADHUGARG)
(MR.HEMANT DIXIT)
PRINCIPAL
OF COMPUTER SCIENCE
HOD
ACKNOWLEDGMENT
I gratefully acknowledge my extreme thanks
towards H.O.D. (C.S.) Hemant dixit R.K.V.M.
(C.B.S.E.) School, thatipur, Gwalior, (M.P.),
Project guide for his valuable guidance,
excellent, supervision & constant
encouragement throughout the entire project
completion.
I am also grateful to principle of R.K.V.M.
(C.B.S.E.) School Mrs.Madhu garg for
providing excellent academic atmosphere in
the institution. I pay may gratitude towards
the principal for unique lab facility and
support for making this endeavour possible.
Lastly I would like to thank my beloved
parents & my dear friends for their
encouragement and cooperation during the
time of working through the project.
AyushPuri
INDEX
Programs
Teacher sign
1.)Sum of two no. from class.
Teacher sign&
Remark
{
Cout<<A+C=<<c;
}
Void main()
{
Abc x;
x.get();
x.disp();
getch();
cout<<"Enter class=";
cin>>clas;
cout<<"enter roll no=";
cin>>roll;
cout<<"Enter marks=";
cin>>marks;
}
void abc::disp()
{
clrscr();
cout<<"\nName="<<name;
cout<<"\nClass="<<clas;
cout<<"\nRoll no.="<<roll;
cout<<"\nMarks="<<marks;
}
int main()
{
abc x;
int ch;
do
{
clrscr();
cout<<"\n\n\nMain menu.\n";
cout<<"1.Input data\n";
cout<<"2.Display data\n";
cout<<"3.Exit\n";
cout<<"Enter your choice(1,2,3:";
cin>>ch;
switch(ch)
{
case 1:x.read();
break;
case 2:x.disp();
break;
default:exit(0);
break;
}
}
while(ch<=1&&ch<=3);
getch();
return 0;
}
Output:-
case'1':area=l*b;
cout<<"AREA="<<area;
break;
case'2':peri=2*(l+b);
cout<<"PERIMETER="<<peri;
break;
case'3':diag=sqrt((l*l)+(b*b));
cout<<"DIAGNOL="<<diag;
break;
case'4':exit(0);
break;
default:cout<<"\t\t\t
WORNG CHOICE...!";
break;
}
}
while(ch1=='y'||ch1=='Y');
getch();
return 0;
}
rsum[i]+=val[i * maxc+j];
}
}
for(j=0;j<maxc;j++)
{
csum[j]=0;
for(i=0;i<maxr;i++)
{
csum[j]+=val[i *maxc+j];
}}
cout<<"The given array along with rowsum & colsum is:\n\n";
for(i=0;i<maxr;i++)
{
for(j=0;j<maxc;j++)
{
cout<<val[i *maxc+j]<<"\t";
}
cout<<rsum[i];
}
for(j=0;j<maxc;j++)
{
cout<<csum[j]<<"\t";
}
cout<<endl;
getch();
return 0;
}
abc x;
x.get();
getch();
}
x.get();
getch();
}
x.cal();
getch();
}
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
ofstream fout;
fout.open("marsk.dat",ios::app);
char ans='y';
int rollno;
float marks;
while(ans=='y'||ans=='Y')
{
cout<<"\nEnter rollno:";
cin>>rollno;
cout<<"\nenter marks=";
cin>>marks;
fout<<rollno<<"\n"<<marks<<"\n";
cout<<"\nWnat to enter more records?(y/n)...";
cin>>ans;
}
fout.close();
return 0;
getch();
}
#include<iostream.h>
#include<conio.h>
int main()
{
void swap(int*x,int*y);
int a,b;
clrscr();
cout<<"Enter A=";
cin>>a;
cout<<"Enter B=";
cin>>b;
clrscr();
cout<<"Original values\n";
cout<<"A="<<a<<",B="<<b<<"\n";
swap(&a,&b);
cout<<"Swapped values \n";
cout<<"A="<<a<<",B="<<b<<"\n";
getch();
return 0;
}
void swap(int*x,int*y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
#include<iostream.h>
#include<conio.h>
int main()
{
char ch;
clrscr();
cout<<"\nEntre a character : ";
cin>>ch;
if(ch >= 48 && ch <= 57)
cout<<"\n"<<"You entered a digit";
else if(ch >= 65 && ch <= 90)
cout<<"\n"<<"You entered an uppercase character";
else if(ch >= 97 && ch <= 122)
cout<<"\n"<<"You entered an lowercase character";
else
cout<<"\n"<<"You entered a special character";
getch();
}
#include<conio.h>
int main()
{
int fv,sv;
int *p1.*p2;
clrscr();
cout<<Enter first value=;
cin>>fv;
cout<<Enter second value=;
cin>>sv;
p1=&fv;
p2=&sv;
*p1=10;
*p2=*p1;
p1=p2;
*p1=20;
cout<<First value=<<fv\n;
cout<<Second value=<<sv\n;
getch();
return 0;
}
int main( )
{
float a[5];
cout << "Enter 5 numbers: ";
for (int i = 0; i < 5; ++i)
{
cin >> *(a+i) ;
}
cout << "Displaying data: " << endl;
for (int i = 0; i < 5; ++i)
{
cout << *(a+i) << endl ;
}
getch();
return 0;
}
int main( )
{
int num[3][2] =
{
{3, 4}, {9, 5}, {7, 1}
};
display(num);
getch();
return 0;
} void display(int n[3][2])
{
cout<<"Displaying Values: "<<endl;
for(int i = 0; i < 3; ++ i)
{
for(int j = 0; j < 2; ++j)
{
cout<<n[i][j]<<" ";
}
}}
int main( )
{
int temperature[CITY][WEEK];
cout<<"Enter all temperature for a week of first city and then
second city. \n";
for (int i = 0; i < CITY; ++i)
{
for(int j = 0; j < WEEK; ++j)
{
cout<<"City "<<i+1<<", Day "<<j+1<<" : ";
cin>>temperature[i][j];
}
}
cout<<"\n\nDisplaying Values:\n";
for (int i = 0; i < CITY; ++i)
{
for(int j = 0; j < WEEK; ++j)
{
cout<<"City "<<i+1<<", Day "<<j+1<<" = "<< temperature[i]
[j]<<endl;
}
}
getch();
return 0;
}
#include<conio.h>
int main( )
{
float number,
sum = 0.0;
do
{
cout<<"Enter a number: ";
cin>>number;
sum += number;
}
while(number != 0.0);
cout<<"Total sum = "<<sum;
getch();
return 0;
}
int main()
{
char ch;
clrscr();
float a,b,result;
cout<<"Enter first number=";
cin>>a;
cout<<"Enter second number=";
cin>>b;
cout<<"Enter any operation (+,-,*,/)=";
cin>>ch;
if (ch=='+')
result=a+b;
else
if (ch=='-')
result=a-b;
else
if (ch=='*')
result=a*b;
else
if (ch=='/')
result=a/b;
else
cout<<"Wrong operator\n";
cout<<"Result is="<<result<<"\n";
getch();
}
#include <iostream.h>
#include<conio.h>
int absolute(int);
float absolute(float);
int main( )
{
int a = -5;
float b = 5.5;
cout<<"Absolute value of "<<a<<" = "<<absolute(a)<<endl;
cout<<"Absolute value of "<<b<<" = "<<absolute(b);
getch();
return 0;
}
int absolute(int var)
{
if (var < 0)
var = -var;
return var;
}
float absolute(float var)
{
if (var < 0.0)
var = -var;
return var;
}
#include<iostream.h>
#include<conio.h>
class line
{
public:
inline float mul(float x,float y)
{
return(x*y);
}
inline float cube(float x)
{
return(x*x*x);
} };
void main()
{
line obj;
float val1,val2;
clrscr();
cout<<"Enter two values:";
cin>>val1>>val2;
cout<<"\nMultiplication value is:"<<obj.mul(val1,val2);
cout<<"\n\nCube value
is :"<<obj.cube(val1)<<"\t"<<obj.cube(val2);
getch();
}
*********