WAP To Print 5 States and Their Capital in Tabular Form
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();
}
#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();
}
#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();
#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();
}
#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();
}
#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();
}
#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();
}
#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();
#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();
#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();}