Académique Documents
Professionnel Documents
Culture Documents
#include<iostream.h> #include<conio.h> void main() {int a,b,c; cout<<"enter first no."; cin>>a; cout<<"enter second no."; cin>>b; c=a+b; cout<<"the result is"<<c; getch(); }
OUTPUT:
#include<iostream.h> #include<conio.h> void main() {int a,b,c; cout<<"enter first no."; cin>>a; cout<<"enter second no."; cin>>b; c=a-b; cout<<"the result is"<<c; getch(); }
OUTPUT:
#include<iostream.h> #include<conio.h> void main() {int a,b,c; cout<<"enter first no."; cin>>a; cout<<"enter second no."; cin>>b; c=a*b; cout<<"the result is"<<c; getch(); }
OUTPUT:
#include<iostream.h> #include<conio.h> void main() {int a,b,c; cout<<"enter first no."; cin>>a; cout<<"enter second no."; cin>>b; c=a/b; cout<<"the result is"<<c; getch(); }
OUTPUT:
#include<iostream.h> #include<conio.h> void main() {int a,b,c,d,e,f; cout<<"enter first no."; cin>>a; cout<<"enter second no."; cin>>b; c=a+b; d=a-b; e=a*b; f=a/b; cout<<"the result of addition is"<<c; cout<<"the result of subtraction is"<<d; cout<<"the result of multiplication is"<<e; cout<<"the result of division is"<<f; getch(); }
OUTPUT:
#include<iostream.h> #include<conio.h> void main() {int r,a; cout<<"enter radius of circle "; cin>>r; a=2*3.14*r*r; cout<<"circumference of circle is"<<a; getch(); }
OUTPUT:
OUTPUT:
#include<iostream.h> #include<conio.h> void main() {int l,b,a; cout<<"enter length of rectangle "; cin>>l; cout<<"enter breadth of rectangle"; cin>>b; a=l*b; cout<<"area of rectangle is"<<a; getch(); }
OUTPUT:
#include<iostream.h> #include<conio.h> void main() { int s,t,a,u; cout<<"enter the value of s "; cin>>s; cout<<"enter the value of t"; cin>>t; cout<<"enter the value of a"; cin>>a; cout<<"enter the value of u"; cin>>u; s=u*t+1/2*a*t*t; cout<<"result is"<<s; getch();
}
OUTPUT:
#include<iostream.h> #include<conio.h> void main() {int a,b,c,d,e,f; cout<<"marks of maths is "; cin>>a; cout<<"marks of english is"; cin>>b; cout<<"marks of science is"; cin>>c; cout<<"marks of hindi is "; cin>>d; cout<<"marks of computer is"; cin>>e; f=a+b+c+d+e/5; cout<<"average marks of 5 subject is"<<f; getch(); }
OUTPUT:
10
OUTPUT:
11
OUTPUT:
12
cin>>a; cout<<"enter your roll no."; cin>>r; cout<<"your name is "<<a<<"\n"; cout<<"your name is"<<r; getch(); }
OUTPUT:
PROGRAM NO 14: WAP for finding whether the no. is even or odd.
#include<iostream.h> #include<conio.h> void main() {clrscr(); int num;
14 Shagun Gupta 90520414178
cout<<"enter no."; cin>>num; if (num % 2==0) cout<<"no. is even"; else cout<<"no. is odd"; getch(); } OUTPUT: for even no.
{clrscr(); int a,b,c; cout<<"enter values"; cin>>a>>b; cout<<"before swapping values are"; cout<<"a is "<<a; cout<<"b is"<<b; c=a; a=b; b=c; cout<<"after swapping values are"; cout<<"a is "<<a; cout<<"b is"<<b; getch(); }
OUTPUT:
{clrscr(); int a,b; cout<<"enter two nos."; cin>>a>>b; if (a>b) cout<<"A is greater"; else cout <<"B is greater"; getch(); }
OUTPUT:
void main() { clrscr(); int a,b,c; cout<<"enter three nos."; cin>>a>>b>>c; if (a>b && a>c) cout<<"A is greater"; else if (b>a && b>c) cout<<"B is greater"; else cout<<" C is greater"; getch(); }
OUTPUT:
PROGRAM NO. 18: WAP to display nos. till you enter zero
18
#include<iostream.h> #include<conio.h> void main() { clrscr(); int i; do { cout<<"enter no."; cin>>i; cout<<"you entered"<<i; } while (i!=0); }
OUTPUT:
#include<conio.h> void main() { clrscr(); int a,b,c; cout<<"enter a,b"; cin>>a>>b; int sum(int,int); c= sum(a,b); cout<<"result is"<<c; getch(); } int sum (int x, int y) {int z; z= x+y; return (z); getch(); }
OUTPUT:
PROGRAM NO. 20: WAP to print days of the week using switch case
#include<iostream.h> #include<conio.h> void main() { 20 Shagun Gupta 90520414178
clrscr; int n; cout<<"enter the no. between 1-7"; cin>>n; switch (n) { case 1:cout<<"monday"; break; case 2:cout<<"tuesday"; break; case 3:cout<<"wednesday"; break; case 4:cout<<"thursday"; break; case 5:cout<<"friday"; break; case 6:cout<<"saturday"; break; case 7:cout<<"sunday"; break; default: cout<<"wrong choice"; } getch();}
OUTPUT:
21
PROGRAM NO. 21: WAP to calculate the factorial of a no. using recursion
#include<iostream.h> #include<conio.h> void main() { clrscr(); int fact = 1,i,n; cout<<"enter the no."; cin>>n; for (i=1;i<=n;i++) fact=fact*i; cout<<"factorial is"<<fact; getch(); }
OUTPUT:
22
OUTPUT:
OUTPUT:
OUTPUT:
25 Shagun Gupta 90520414178
OUTPUT:
OUTPUT:
27 Shagun Gupta 90520414178
} Output:
28
Program no.28 WAP for function with no argument and no return value.
#include<conio.h> #include<iostream.h> void main() { clrscr(); void add(); add(); getch(); } void add()
29 Shagun Gupta 90520414178
Output:
OUTPUT:
OUTPUT:
33 Shagun Gupta 90520414178
clrscr(); struct student s1,s2,s3; cout<<"enter the record of first student"<<"\n"; cout<<"enter name"<<"\n"; cin>>s1.name; cout<<"enter roll no."<<"\n"; cin>>s1.r; cout<<"enter trade"<<"\n"; cin>>s1.trade; cout<<"record of first student is"<<"\n"; cout<<"name is"<<s1.name<<"\n";
34 Shagun Gupta 90520414178
cout<<"roll no. is"<<s1.r<<"\n"; cout<<"trade is"<<s1.trade<<"\n"; cout<<"enter the record of second student"<<"\n"; cout<<"enter name"<<"\n"; cin>>s2.name; cout<<"enter roll no."<<"\n"; cin>>s2.r; cout<<"enter trade"<<"\n"; cin>>s3.trade; cout<<"record of second student is"<<"\n"; cout<<"name is"<<s2.name<<"\n"; cout<<"roll no. is"<<s2.r<<"\n"; cout<<"trade is"<<s2.trade<<"\n"; getch(); }
OUTPUT:
35
Program No.34 WAP to enter the student information using array with structure.
#include<iostream.h> #include<conio.h> struct student {char name[30],trade[30]; int r; }; void main() { clrscr(); struct student s[200]; int n,i; cout<<"enter the no. of students"; cin>>n; for(i=1;i<+n;i++) {cout<<"enter the information of"<<i<<"student"<<"\n"; cout<<"enter name"<<"\n"; cin>>s[i].name; cout<<"enter roll no."<<"\n"; cin>>s[i].r; cout<<"enter trade"<<"\n"; cin>>s[i].trade;} for(i=1;i<=n;i++) 36 Shagun Gupta 90520414178
{cout<<"record of "<<i<<"student is"<<"\n"; cout<<"name is"<<s[i].name<<"\n"; cout<<"roll no. is"<<s[i].r<<"\n"; cout<<"trade is"<<s[i].trade<<"\n"; } getch(); }
OUTPUT:
OUTPUT:
37
Program No.36 WAP for member function inside the class definition.
#include<iostream.h> #include<conio.h> class student { private: int r; char name[30]; public: void enter() { cout<<"enter the name of student"; cin>>name; cout<<"enter roll number of student"; cin>>r; } void display() { cout<<"name of student is"<<name<<"\n"; cout<<"roll number of student is"<<r;
38 Shagun Gupta 90520414178
OUTPUT:
39