Академический Документы
Профессиональный Документы
Культура Документы
EXPERIMENT:-1
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
getch();
1
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
EXPERIMENT:-2
2
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int a,b,add,sub,multiply,divide,modulus;
cin>>a;
cin>>b;
add=a+b;
cin>>a;
cin>>b;
sub=a-b;
cin>>a;
3
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
cin>>b;
multiply=a*b;
cin>>a;
cin>>b;
divide=a/b;
cin>>a;
cin>>b;
modulus=a%b;
getch();
4
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
EXPERIMENT:-3
5
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int a,b,c;
cin>>a;
cin>>b;
cin>>c;
getch();
6
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
EXPERIMENT:-4
CODE:-
#include<iostream.h>
7
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
#include<conio.h>
void main()
clrscr();
int a;
cin>>a;
if(a%2==0)
else
getch();
OUTPUT:-
8
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-5
9
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int a;
cin>>a;
if(a>0)
else if(a<0)
else
getch();
OUTPUT:-
10
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-6
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
11
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
clrscr();
int a,b,c;
cin>>a;
cin>>b;
cin>>c;
if(a>b&&a>c)
cout<<”\n a is greater”;
else if(b>a&&b>c)
cout<<”\n b is greater”;
else
cout<<”\n c is greater”;
getch();
12
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
13
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-7
CODE:-
#include<iostream.h>
#include<conio.h>
14
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
void main()
clrscr();
cin>>cel;
frh=(1.8*cel)+32;
getch();
OUTPUT:-
15
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-8
TITLE :- Write a program to find whether the student is eligible for exams
according to their attendance and marks .
CODE:-
16
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int marks,atten;
cin>>marks;
cin>>atten;
if(marks>40||atten>75)
else
getch();
OUTPUT:-
17
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-9
CODE:-
#include<iostream.h>
18
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
#include<conio.h>
int a=20;
void main()
clrscr();
int a=60;
int b=a;
int a=30;
getch():
19
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
20
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-10
CODE:-
#include<iostream.h>
#include<conio.h>
21
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
void main()
clrscr();
int a,b,c,d,e,t,sum,count;
float average;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
cin>>count;
sum=a+b+c+d+e;
average=sum/count;
22
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
average=(float)sum/count;
getch();
OUTPUT:-
23
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-11
CODE:-
#include<iostream.h>
#include<conio.h>
24
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
#include<iomanip.h>
void main()
{
clrscr();
int i, time;
float p,r,interest;
for(i=1;i<=3;i++)
{
cout<<"\n enter the value of p = ";
cin>>p;
cout<<"\n enter the value of r = ";
cin>>r;
cout<<"\n enter the value of time = ";
cin>>time;
interest=(p*r*time)/100;
cout<<"\n value of interest:";
cout<<setw(26)<<interest;
getch();
}
}
OUTPUT:-
25
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-12
26
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
1. Credit
2. Debit
3. Balance enquiry
The program will ask the user to select appropriate case and print the new
amount as output.
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,amount,choice;
cout<<"\n enter initial amount: ";
cin>>a;
cout<<"\n 1:credit";
cout<<"\n 2:debit";
cout<<"\n 3:balance enquiry:";
cout<<"\n please enter your choice: ";
cin>>choice;
switch(choice)
{
case 1:
{
cout<<"\n please enter amount to be credit= ";
cin>>b;
27
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
amount=a+b;
cout<<" \n amount after credit : "<<amount;
break;
}
case 2:
{
cout<<"\n enter the amount of debit= ";
cin>>b;
if(a>b)
{
amount=a-b;
cout<<"\n amount after debit : "<<amount; }
else
{
cout<<"\n you dont have enough amount";
}
break;
}
case 3:
{
amount=a;
cout<<"\n your current amount is = "<<amount;
break;
}
default:
{
cout<<"\n please enter the correct choice";
break;
}}
getch();
}
28
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
29
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
30
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-13
CODE:
#include<iostream.h>
#include<conio.h>
float add(float, float);
float sub(float, float);
float multiply(float, float);
float divide(float, float);
void main()
{
clrscr();
float a,b;
cout<<"\n enter any two numbers : ";
cin>>a>>b;
cout<<"\n sumation "<<add(a,b);
cout<<"\n subtraction "<<sub(a,b);
cout<<"\n multiplication "<<multiply(a,b);
cout<<"\n division "<<divide(a,b);
getch();
}
float add(float x, float y)
{
float res;
res=x+y;
return res;
}
float sub(float x, float y)
{
31
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
float res;
res=x-y;
return res;
}
float multiply(float x,float y)
{
float res;
res=x*y;
return res;
}
float divide(float x, float y)
{
if(y==0)
{
cout<<"\n divide by zero error...!!!";
cout<<"\n press any key to exit...!!!";
getch();
}
else
{
float res;
res=x/y;
return res;
}
}
32
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
33
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-14
CODE:-
#include<iostream.h>
#include<conio.h>
class operation
{
int a,b,add,sub;
public:
void get();
void sum();
void difference();
};
inline void operation::get()
{
cout<<"\n enter first value= ";
cin>>a;
cout<<"\n enter second value= ";
cin>>b;
}
inline void operation::sum()
{
add=a+b;
cout<<"\n additon of two numbers: "<<add;
}
inline void operation::difference()
{
sub=a-b;
cout<<"\n\n difference of two numbers: "<<sub;
34
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
}
void main()
{
clrscr();
cout<<"\n program using inline function";
operation s;
s.get();
s.sum();
s.difference();
getch();
}
35
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
36
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-15
CODE:-
#include<iostream.h>
#include<conio.h>
class sahil
{
int a;
int b;
public:
void setvalue()
{
a=4;
b=7;
}
friend float mean(sahil s);
};
float mean(sahil s)
{
return float(s.a+s.b)/2.0;
}
void main()
{
clrscr();
sahil x;
x.setvalue();
cout<<"\n the final value is "<<mean(x);
getch();
}
37
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
38
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-16
CODE:-
#include <iostream.h>
#include<conio.h>
class abc;
class xyz
{
int x;
public:
void setvalue (int i)
{
x=i;
}
friend void max (xyz , abc );
};
class abc
{
int a;
public:
void setvalue (int i)
{
a= i;
}
friend void max(xyz,abc);
};
void max(xyz m , abc n)
{
39
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
if(m.x>=n.a)
{
cout<<m.x;
}
else
{
cout<<n.a;
}}
void main ()
{
abc d;
d.setvalue(10);
xyz e;
e.setvalue(16);
max(e,d);
getch();
}
40
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
41
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-17
CODE:-
#include<iostream.h>
#include<conio.h>
class number
{
private:
int a;
public:
void getnum(int x);
friend void printnum(number num)
};
void number::getnum(int x)
{
a=x;
}
void printnum(number num)
{
cout<<"\n value of a(private data member of class memeber):"<<num.a;
}
void main()
{
clrscr();
number nobj;
nobj.getnum(2000);
printnum(nobj);
getch();
}
42
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
43
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-18
CODE:-
#include<iostream.h>
#include<conio.h>
class Box
{
double width;
public:
friend void printwidth(Box box);
void setwidth( double wid );
};
void Box ::setwidth(double wid)
{
width = wid;
}
void printwidth ( Box box )
{
cout<<"\n Width of box : "<<box.width <<endl;
}
void main()
{
clrscr();
Box box ;
44
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
box.setwidth(10.9);
printwidth(box);
getch();
}
OUTPUT:-
45
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-19
CODE:-
#include<iostream.h>
#include<conio.h>
class example
{
private:
int a;
public:
void getdata()
{
cout<<"\n enter value of a:";
cin>>a;
friend void findmax(example , example);
};
void findmax(example e1,example e2)
{
if(e1.a>e2.a)
cout<<"\n data of object e1 is greater ";
else if(e1.a<e2.a)
46
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
47
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
48
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-20
CODE:-
#include<iostream.h>
#include<conio.h>
int factorial(int n);
void main()
{
clrscr();
int n;
cout<<"\n enter a positive integer:";
cin>>n;
cout<<"\n factorial of "<<n<<"="<<factorial(n);
getch();
}
int factorial(int n)
{
if(n>1)
return n*factorial(n-1);
else
49
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
return 1;
}
OUTPUT:-
50
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-21
CODE:-
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,fact=1,number;
cout<<"\n enter any number:";
cin>>number;
for(i=1;i<=number;i++)
{
fact=fact*i;
}
cout<<"\n factorial of "<<number<<" is "<<fact;
getch();
}
51
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
52
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-22
CODE:-
#include<iostream.h>
#include<conio.h>
class employee
{
char name[30];
float age;
public:
void getdata(void);
void putdata(void);
};
void employee::getdata(void)
{
53
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
54
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
55
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-23
CODE:-
#include<iostream.h>
#include<conio.h>
class test
{
int code;
static count;
public:
void setcode(void)
{
code=++count;
}
void showcode(void)
{
56
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
57
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
58
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-24
CODE:-
#include<iostream.h>
#include<conio.h>
class item
{
static int count;
int number;
public:
void getdata(int a)
{
number=a;
count++;
}
void getcount(void)
{
59
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
60
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
61
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-25
CODE:_
#include<iostream.h>
#include<conio.h>
class set
{
int m,n;
public:
void input(void);
void display(void);
int largest(void);
};
int set::largest(void)
{
if(m>=n)
return(m);
else
62
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
return(n);
}
void set::input(void)
{
cout<<"\n input value of m and n ";
cin>>m>>n;
}
void set::display (void)
{
cout<<"\n largest value= ";
cout <<largest()<<"\n";
}
void main()
{
clrscr();
set a;
a.input();
a.display();
getch();
}
63
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
64
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-26
CODE:
#include<iostream.h>
#include<conio.h>
class integer
{
int m,n;
public:
integer(int, int);
void display(void)
{
cout<<"\n m = "<<m;
cout<<"\n n = "<<n;
}
};
integer::integer(int x, int y)
{
65
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
m=x;
n=y;
}
void main()
{
clrscr();
integer int1(0,900);
integer int2=integer(45,75);
cout<<"\n object1 ";
int1.display();
cout<<"\n object2 ";
int2.display();
getch();
}
66
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
67
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
EXPERIMENT:-27
TITLE:- Write a program for constructor overloading with the help of class.
CODE:_
#include<iostream.h>
#include<conio.h>
class complex
{
float x,y;
public:
complex(){}
complex (float a)
{
x=y=a;
}
complex( float real, float imag)
{
x=real;
y=imag;
}
friend complex sum(complex, complex);
68
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
69
REG.NO. -317021002
DEPARTMENT OF COMPUTER SCIENCE ENGINEERING
OUTPUT:-
70
REG.NO. -317021002