Thursday, 20 October 2016

to find which is greatrer


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
cout<<" enter first number:: ";
cin>>a;
cout<<" enter second number:: ";
cin>>b;
cout<<" enter third number:: ";
cin>>c;
if(a>b)
 {if(a>c)
   cout<<"  "<< a <<" is greater ";
  else
   cout<<"  "<< c <<" is greater ";
 }
else
 {if(b>c)
   cout<<"  "<< b <<" is greater ";
  else
   cout<<"  "<< c <<" is greater ";
 }
getch();
}

Wednesday, 19 October 2016

Add.sub.mul and div by switch

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,d,ch;
cout<<"enter the number";
cin>>a>>b;
cout<<"1.Addition of number\n";
cout<<"2.Substraction of number\n";
cout<<"3.Multiplication of number\n";
cout<<"4.Division of number\n";
cout<<"enter your choice for operation of numbers\n";
cin>>ch;
switch(ch)
{
case 1:
d=a+b;
cout<<"the sum of numbers will be\n"<<d;
break;
case 2:
d=a-b;
cout<<"the difference of numbers will be\n"<<d;
break;
case 3:
d=a*b;
cout<<"the product of numbers will be\n"<<d;
break;
case 4:
d=a/b;
cout<<"the division of numbers will be\n"<<d;
break;
default:
cout<<"the entered choice is invalid";
break;
}
getch();
}

PROGRAMME FOR ADD,SUBS,MUL,DIV BY SWITCH STATEMENT

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,d,ch;
cout<<"enter the number";
cin>>a>>b;
cout<<"1.Addition of number\n";
cout<<"2.Substraction of number\n";
cout<<"3.Multiplication of number\n";
cout<<"4.Division of number\n";
cout<<"enter your choice for operation of numbers\n";
cin>>ch;
switch(ch)
{
case 1:
d=a+b;
cout<<"the sum of numbers will be\n"<<d;
break;
case 2:
d=a-b;
cout<<"the difference of numbers will be\n"<<d;
break;
case 3:
d=a*b;
cout<<"the product of numbers will be\n"<<d;
break;
case 4:
d=a/b;
cout<<"the division of numbers will be\n"<<d;
break;
default:
cout<<"the entered choice is invalid";
break;
}
getch();
}

Area of various shapes

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float l,b,r,d,s,h;
int ch;
cout<<"1.Area of square\n";
cout<<"2.Area of rectangle\n";
cout<<"3.Area of triangle\n";
cout<<"4.Area of circle\n";
cout<<"choose the polygon whose area is to be calculated\n";
cin>>ch;
switch(ch)
{
case 1:
cout<<"enter the lenght of side\n";
cin>>s;
d=pow(s,2);
cout<<"the area of square is\n"<<d;
break;
case 2:
cout<<"enter the lenght and breadth respectively\n";
cin>>l;
cin>>b;
d=l*b;
cout<<"the area of rectangle is\n"<<d;
break;
case 3:
cout<<"enter the lenght of base and height respectively\n";
cin>>b;
cin>>h;
d=0.5*b*h;
cout<<"the area of triangle is\n"<<d;
break;
case 4:
cout<<"enter the radius\n";
cin>>r;
d=3.14*r*r;
cout<<"the area of circle is\n"<<d;
break;
default:
cout<<"the entered choice is invalid";
break;
}
getch();
}

PROGRAMME FOR AREA OF DIFFERENT POLYGONS BY USING SWITCH STATEMENT

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float l,b,r,d,s,h;
int ch;
cout<<"1.Area of square\n";
cout<<"2.Area of rectangle\n";
cout<<"3.Area of triangle\n";
cout<<"4.Area of circle\n";
cout<<"choose the polygon whose area is to be calculated\n";
cin>>ch;
switch(ch)
{
case 1:
cout<<"enter the lenght of side\n";
cin>>s;
d=pow(s,2);
cout<<"the area of square is\n"<<d;
break;
case 2:
cout<<"enter the lenght and breadth respectively\n";
cin>>l;
cin>>b;
d=l*b;
cout<<"the area of rectangle is\n"<<d;
break;
case 3:
cout<<"enter the lenght of base and height respectively\n";
cin>>b;
cin>>h;
d=0.5*b*h;
cout<<"the area of triangle is\n"<<d;
break;
case 4:
cout<<"enter the radius\n";
cin>>r;
d=3.14*r*r;
cout<<"the area of circle is\n"<<d;
break;
default:
cout<<"the entered choice is invalid";
break;
}
getch();
}

PROGRAMME FOR MARKS,PERCENTAGE AND GRADE

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,m,c,p,e,k,o;
int xy;
cout<<"enter the marks obtained in maths\n";
cin>>m;
cout<<"enter the marks obtained in physics\n";
cin>>p;
cout<<"enter the marks obtained in chemistry\n";
cin>>c;
cout<<"enter the marks obtained in english\n";
cin>>e;
cout<<"enter the marks obtained in computer science\n";
cin>>k;
a=(m+p+c+e+k)/5;
cout<<"the average marks will be\n"<<a<<"\n";
o=5*a*0.5;
cout<<"the overall percentage achieved will be\n"<<o<<"\n";
cout<<"1.If overall percentage is => 90\n";
cout<<"2.If overall percentage is between 89-80\n";
cout<<"3.If overall percentage is between 79-70\n";
cout<<"4.If overall percentage is between 69-60\n";
cout<<"5.If overall percentage is between 59-50\n";
cout<<"6.If overall percentage is < 50\n";
cout<<"enter your choice\n";
cin>>xy;
switch(xy)
{
case 1:
cout<<"the grade awarded will be\n"<<"A";
break;
case 2:
cout<<"the grade awarded will be\n"<<"B";
break;
case 3:
cout<<"the grade awarded will be\n"<<"C";
break;
case 4:
cout<<"the grade awarded will be\n"<<"D";
break;
case 5:
cout<<"the grade awarded will be\n"<<"E";
break;
case 6:
cout<<"ohhh nooo...............FAIL";
break;
default:
cout<<"the entered category is invalid";
break;
}
getch();
}

PROGRAMME TO GET AMAZING NUMBER WITH YOUR AGE

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
cout<<"enter your age";
cin>>a;
b=259*39*a;
cout<<"your age repeats three times"<<"\n"<<b;
getch();
}

PROGRAMME FOR ROOTS OF QUADRATIC EQUATION

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,x,y;
int ch;
cout<<"1.first root of eqn\n";
cout<<"2.second root of eqn\n";
cout<<"enter your choice\n";
cin>>ch;
switch(ch)
{
case 1:
cout<<"enter the coefficient of x^2\n";
cin>>a;
cout<<"enter the coefficient of x\n";
cin>>b;
cout<<"enter the constant term\n";
cin>>c;
x=-b+sqrt(b*b-4*a*c)/2*a;
cout<<"the first root will be\n"<<x;
break;
case 2:
cout<<"enter the coefficient of x^2\n";
cin>>a;
cout<<"enter the coefficient of x\n";
cin>>b;
cout<<"enter the constant term\n";
cin>>c;
y=-b-sqrt(b*b-4*a*c)/2*a;
cout<<"the second root will be\n"<<y;
break;
default:
cout<<"the entered choice is invalid";
}
getch();
}

PROGRAMME FOR INCOME TAX ON MONTHLY SALARY

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
int xy;
cout<<"1.If monthly salary is > 9000\n";
cout<<"2.If monthly salary is in between 7500-8999\n";
cout<<"3.If monthly salary is <=7499\n";
cout<<"enter your salary category\n";
cin>>xy;
switch(xy)
{
case 1:
cout<<"enter your monthly salary\n";
cin>>a;
b=a*40*0.01;
cout<<"the income tax to be pay will be\n"<<b;
break;
case 2:
cout<<"enter your monthly salary\n";
cin>>a;
b=a*30*0.01;
cout<<"the income tax to be pay will be\n"<<b;
break;
case 3:
cout<<"enter your monthly salary\n";
cin>>a;
b=a*20*0.01;
cout<<"the income tax to be pay will be\n"<<b;
break;
default:
cout<<"the entered category is invalid";
break;
}
getch();
}

PROGRAMME FOR ELECTRICITY BILL

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,m,n,t;
int xy;
cout<<"enter the number of users\n";
cin>>n;
cout<<"enter the charge of meter\n";
cin>>m;
cout<<"1.If the units consumed is 100-199\n";
cout<<"2.If the units consumed is between 200-299\n";
cout<<"3.If the units consumed is =>300\n";
cout<<"enter the choice\n";
cin>>xy;
switch(xy)
{
case 1:
cout<<"enter the electricity consumed in units\n";
cin>>a;
b=a*0.40;
t=b+m/n;
cout<<"the total charge of electricity including meter charge by single user in Rs. will be\n"<<t;
break;
case 2:
cout<<"enter the electricity consumed in units\n";
cin>>a;
b=a*0.50;
t=b+m/n;
cout<<"the total charge of electricity including meter charge by single user in Rs. will be\n"<<t;
break;
case 3:
cout<<"enter the electricity consumed in units\n";
cin>>a;
b=a*0.60;
t=b+m/n;
cout<<"the total charge of electricity including meter charge by single user in Rs. will be\n"<<t;
break;
default:
cout<<"the entered category is invalid";
break;
}
getch();
}

PROGRAMME FOR AREA OF DIFFERENT POLYGONS BY USING SWITCH STATEMENT

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float l,b,r,d,s,h;
int ch;
cout<<"1.Area of square\n";
cout<<"2.Area of rectangle\n";
cout<<"3.Area of triangle\n";
cout<<"4.Area of circle\n";
cout<<"choose the polygon whose area is to be calculated\n";
cin>>ch;
switch(ch)
{
case 1:
cout<<"enter the lenght of side\n";
cin>>s;
d=pow(s,2);
cout<<"the area of square is\n"<<d;
break;
case 2:
cout<<"enter the lenght and breadth respectively\n";
cin>>l;
cin>>b;
d=l*b;
cout<<"the area of rectangle is\n"<<d;
break;
case 3:
cout<<"enter the lenght of base and height respectively\n";
cin>>b;
cin>>h;
d=0.5*b*h;
cout<<"the area of triangle is\n"<<d;
break;
case 4:
cout<<"enter the radius\n";
cin>>r;
d=3.14*r*r;
cout<<"the area of circle is\n"<<d;
break;
default:
cout<<"the entered choice is invalid";
break;
}
getch();
}

loop for a table of any no

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,n;
cout<<"enter the number whose table is to be print"<<"\n";
cin>>n;
for(int i=1;i<=10;i++)
{
cout<<"\n"<<i*n;
}
getch();
}

Sunday, 9 October 2016

To print series 1,-4,7.....

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x=-1,y=1,i;
cout<<"Enter the no. of terms you want to print ";
cin>>i;
for (int z=0;z<=i;z++)
{
   z=x+y;
   cout<<z<<"\n";
   x=y;
   y=z;
}
getch();
}

Wednesday, 5 October 2016

wap of printing first 10 natural no by loop

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
for(int i=1;i<=10;i++)
{
cout<< i<<" ";
}
getch();
}

converting temperature by switch

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
float c,f;
cout<<" 1 For farenhiet to celsius "<<"\n";
cout<<" 2 For celsius to farenhiet"<<"\n";
cout<<" ENTER YOUR CHOICE  "<<"\n";
cin>>a;
switch(a)
{
case 1:
 cout<<"enter the temp in farenhiet-:";
 cin>>f;
 c=(5*f-160)/9;
 cout<<"temp in celsius is -: "<<c;
 break;
case 2:
 cout<<"enter the temp in celsius -: " ;
 cin>>c;
 f=9/5*c+32;
 cout<<"temp in farenhiet is -: "<<f;
 break;
default:
 cout<<"invalid input";
 break;
 }
getch();
}