j
Showing posts with label Cpp ch 2 Program. Show all posts
Showing posts with label Cpp ch 2 Program. Show all posts

Wednesday, 25 November 2015

Write a program that take grade A,B,C and D if user enter A then Display Exelent if enter B then Good if Enter C Average and if Enter D then Display Poor

Program

#include<iostream.h>
#include<conio.h>
void main()
{
char grd;
cout<<"Enter grade A,B,C or D...";
grd=getche();
if(grd=='a'||grd=='A')
cout<<"\nEXCELENT";
else if(grd=='B'||grd=='b')
cout<<"\nGOOD";
else if(grd=='c'||grd=='C')
cout<<"\nAVERAGE";
else if(grd=='d'||grd=='D')
cout<<"\nPOOR";
else
cout<<"\nINVALID GRADE";
getch();
}


Output

 

Friday, 13 November 2015

Write a temperature conversion program that gives the user the option to converting the fahrenheit to Celsius to Fahrenheit. Then convert accourding to choice

 Program

Write a temperature conversion program that gives the user the option to converting the Fahrenheit to Celsius to Fahrenheit. Then carry out the conversion. Interaction of the program might look like this
       Enter 1 for convert Fahrenheit to Celsius.
       Enter 2 for convert Celsius to Fahrenheit.

Program Solution....

 #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int op;
float f,c;
cout<<"Enter the choice\n Enter 1 for convert Fahrenheit to Celsius.\nEnter 2 for convert Celsius to Fahrenheit.";
cin>>op;
if(op==1)
cout<<"Enter the Celsius";
cin>>c;
f=9/5*c+32;
cout<<Fahrenheit =======>>>"<<f;
else if(op==2)
cout<<"Enter the Fahrenheit ";
cin>>f;
f=5/9*f-32;
cout<<Celsius =======>>>"<<f;
else
cout<<"Invalid Choice "
getch();
}

Sunday, 8 November 2015

Write a program that take two number from user and check second number square of first number or not

Program Solution

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter two numbers ::";
cin>>a>>b;
if(a*a==b)
cout<<"Second number is the square of first.";
else
cout<<"Its is not a square of first.";
getch();
}

OUTPUT