Sunteți pe pagina 1din 23

WAP to print 5 states and their capital in tabular form.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"\n\n\n\n\t\t\tSTATES CAPITAL";
cout<<"\n1.\t\t\tUttar Pradesh Lucknow";
cout<<"\n2\t\t\tPunjab Chandigarh";
cout<<"\n3.\t\t\tBihar Patna";
cout<<"\n4.\t\t\tMaharashtra Mumbai";
cout<<"\n5.\t\t\tJharkhand Ranchi";
getch();
}
WAP to print result of a student, accept marks in 3 subjects.
Print total and average in tabular form.

#include<conio.h>
#include<iostream.h>
#include<math.h>
void main()
{
clrscr();
float m1,m2,m3,t,avg;
cout<<"Enter marks in Physics(out of 100)::";
cin>>m1;
cout<<"Enter marks in Chemistry(out of 100)::";
cin>>m2;
cout<<"Enter marks in Mathematics(out of 100)::";
cin>>m3;
t=m1+m2+m3;
avg=(m1+m2+m3)/3;
cout<<"\n\nYour Total is::"<<t;
cout<<"\nYour Average is::"<<avg;
getch();
}
WAP to print area of a circle.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float r,a;
cout<<"Enter the Radius of the circle::";
cin>>r;
a=(3.14)*r*r;
cout<<"\nThe area of the circle is::"<<a;
getch();
}
WAP to print area of a square

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float s,a;
cout<<"Enter the side of the square:: ";
cin>>s;
a=s*s;
cout<<"\nThe area of the square is:: "<<a;
getch();
}
WAP to print area of a triangle

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float s1,s2,s3,s,ar;
cout<<"Enter the Sides of the triangle::\n";
cout<<"SIDE1::";
cin>>s1;
cout<<"SIDE2::";
cin>>s2;
cout<<"SIDE3::";
cin>>s3;
s=(s1+s2+s3)/2;
ar=sqrt((s)*(s-s1)*(s-s2)*(s-s3));
cout<<"\nThe area of the triangle is::"<<ar;
getch();
}

WAP to print area of a rectangle.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float l,b,a;
cout<<"Enter the Length of the rectangle::";
cin>>l;
cout<<"Enter the Breadth of the rectangle::";
cin>>b;
a=l*b;
cout<<"\nThe area of the rectangle is::"<<a;
getch();
}

WAP to print Simple Interest.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float p,r,t,si;
cout<<"Enter Principal,Rate,Time::\n";
cout<<"Principal::";
cin>>p;
cout<<"Rate::";
cin>>r;
cout<<"Time::";
cin>>t;
si=(p*r*t)/100;
cout<<"Your SI is::"<<si;
getch();

WAP to print result of 3 students in 5 subjects. Print total


and average.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float p1,p2,p3,c1,c2,c3,m1,m2,m3,t1,t2,t3,a1,a2,a3;
cout<<"Enter marks of student#1::\n";
cout<<"Physics::\t";
cin>>p1;
cout<<"Chemistry::\t";
cin>>c1;
cout<<"Mathematics::\t";
cin>>m1;
t1=p1+c1+m1;
a1=(t1)/3;
cout<<"The total of student#1 is:::\t"<<t1;
cout<<"\nThe average of student#1 is:::\t"<<a1;
cout<<"\n\nEnter marks of student#2::\n";
cout<<"Physics(out of 100)::\t";
cin>>p2;
cout<<"Chemistry::\t";
cin>>c2;
cout<<"Mathematics::\t";
cin>>m2;
t2=p2+c2+m2;
a2=(t2)/3;
cout<<"The total of student#2 is:::\t"<<t2;
cout<<"\nThe average of student#2 is:::\t"<<a2;
cout<<"\n\nEnter marks of student#3::\n";
cout<<"Physics::\t";
cin>>p3;
cout<<"Chemistry::\t";
cin>>c3;
cout<<"Mathematics::\t";
cin>>m3;
t3=p3+c3+m3;
a3=(t3)/3;
cout<<"The total of student#3 is:::\t"<<t3;
cout<<"\n1The average of student#3 is:::\t"<<a3;
getch();
}

WAP to print square root of a number.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float m,n;
cout<<"Enter the no. of which you hace to find a Sq.Root::";
cin>>m;
n=sqrt(m);
cout<<"The Sq.Root of "<<m<<" is "<<n;
getch();
}
WAP to print ASCII value of a character.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
char ch;
cout<<"Enter a character::";
cin>>ch;
int x=ch;
cout<<"The ASCII value of "<<ch<<" is "<<x<<".";
getch();
}
WAP to accept a character and print next 4 characters.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int x,y;
char c,t;
cout<<"Enter an alphabet:: ";
cin>>c;
x=c;
cout<<"Alphabet enter is:: "<<c;
cout<<"\nNext 4 alphabets are::\t";
for(int i=1; i<=4; i++)
{
x++;
t=x;
cout<<t<<"\t";
}
getch();
}

WAP to accept a character and print it in opposite case.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
int x,y;
char a,b;
cout<<"Enter a character::";
cin>>a;
x=a;
if (x>=65 && x<=90)
{
y=x+32;
b=y;
cout<<"The char. entered by you is an uppercase char. and its
lowercase is::"<<b;
}
else
{
y=x-32;
b=y;
cout<<"The char. entered by you is a lowercase char. and its
uppercase is::"<<b;
}
getch();
}

WAP to accept age and print Yes/No for eligible to vote.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
int x;
cout<<"Enter your age::";
cin>>x;
if (x>=18)
{
cout<<"You are eligible to vote";
}
else
{
cout<<"You are not eligible to vote";
}
getch();
}

WAP to calculate the Gross Salary.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
int e,s,g;
cout<<"Enter your salary::";
cin>>s;
cout<<"\nEnter your experience";
cin>>e;
if (e>10)
{
g=(s)+((32/100)*(s))+(20000)-((12/100)*(s))+((30/100)*(s));
cout<<"Your GROSS SALARY is::"<<g;
}
if (e<10 && e>1)
{
g=(s)+((32/100)*(s))+(10000)-((12/100)*(s))+((30/100)*(s));
cout<<"Your GROSS SALARY is::"<<g;
}
if (e<1 && s<1)
{
cout<<"<<<!!!WRONG INPUT!!!>>>";
}
getch();
}

WAP to print length in inches and foot from centimeters.


#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
float i,f,c;
cout<<"Enter length(in cms)::::";
cin>>c;
i=c/(2.5);
f=c/(30);
cout<<"Length in INCHES is "<<i<<".";
cout<<"\nLength in FOOT is "<<f<<".";
getch();
}
WAP to print square of a number if its even else print cube.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
int x;
cout<<"Enter a no.(IF NO.IN DECIMAL FORM IT WILL
TAKE THE NO. BEFORE THE DECIMAL)::";
cin>>x;
if ((x%2)==0)
{
long a=x*x;
cout<<"The no. entered by you is even and its square is::"<<a;
}
if ((x%2)==1)
{
int a=x*x*x;
cout<<"The no. entered by you is odd and its cube is::"<<a;
}
getch();
}
WAP to print whether entered number positive or negative.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long double x;
cout<<"Enter a no.";
cin>>x;
if (x>0)
{
cout<<"No. entered by you is +ve.";
}
if (x<0)
{
cout<<"No. entered by you is -ve.";
}
if (x==0)
{
cout<<"The no. is nor +VE nor -VE.";
}
getch();
WAP to accept a character and print if it’s a upper case or
lower case.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
int n;
cout<<"Enter numeric day:::";
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;
}
if (n<1 || n>7)
{
cout<<"Invalid";
}
getch();

WAP to accept numeric day of week and print its character


day.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
int x;
cout<<"Enter a character::";
cin>>ch;
x=ch;
if (x>=65 && x<=90)
{
cout<<"Character entered by you is an UPPERCASE character";
}
else
{
if (x>=97 && x<=123)
{
cout<<"Character entered by you is a LOWERCASE character";
}
else
{
cout<<"Its a digit";
}
}
getch();

WAP to accept a character and find if it’s a vowel or


consonant.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
char character;
int a;
cout<<"Enter a character::";
cin>>character;
a=character;
if((a>=65 && a<=90) || (a>=97 && a<=122))
//if( 97 <= (int) character <= 122 && 65 <= (int) character <=90)
{
switch(character)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
cout<<"vowel";
break;
default:
cout<<"consonant";
break;
}
}
else
cout<<"not a letter";
getch();}

S-ar putea să vă placă și