assignment cpp simple program

 write a program to accept temperature in fahreheit and print it in
centigrade

#include<iostream.h>
#include<conio.h>
int main()
{
float centigrade,fahreheit;
clrscr();

cout<<"centigrade value=";
cin>>centigrade;

fahreheit=centigrade*1.8+32;

cout<<"centigrade value is="<<centigrade<<endl;
cout<<"fahreheit value is="<<fahreheit<<endl;

getch();
return 0;
}

OUTPUT
cetigrade value=23
centigrade value is=23
fahreheit value is=73.40002





write a program to find sum of two value.

#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int first,second,sum;

cout<<"enter first value=";
cin>>first;

cout<<"enter second value=";
cin>>second;

sum=first+second;

cout<<"sum="<<sum;
getch();
return 0;
}


OUTPUT
enter first value=5
enter second value=5
sum=10

write a program to swap the value of two variable.


#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int apple,banana;

cout<<"eat apple=";
cin>>apple;


cout<<"eat banana=";
cin>>banana;

apple=apple+banana;
banana=apple-banana;
apple=apple-banana;

cout<<"how many fruit first eatting ?"<<endl<<"apple="<<apple<<endl<<"banana="<<banana;

getch();
return 0;
}
OUTPUT
eat apple=2
eat banana=1
how many fruit first eatting ?
apple=1 banana=2

write a program to find the large number using ternary operator
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int x,y,z,largest;

cout<<"enter three number=";
cin>>x>>y>>z;

largest=(x>y)?
    (x>z?x:z):(y>z?y:z);

cout<<"largest number="<<largest;

getch();
return 0;
}
OUTPUT
enter three number=5
9
1 largest number=9
write a program to takes length as input in feet and inches. the program should then convert the lengths in centimeter and display it on screen. assume that the given lengths in feet and inches are integer


#include<iostream.h>
#include<conio.h>

const double CENTIMETERS_PER_INCH=2.54;
const int INCHES_PER_FOOT=12;

int main()
{
clrscr();
int FEET,inches;
int totalInches;
double centimeters;

cout<<"enter two integer"<<endl<<"one feet and second inches=";
cin>>FEET>>inches;

cout<<endl;
cout<<"you enter number are"<<FEET<<"for feet and"<<endl<<inches<<"for inches"<<endl;
cout<<endl;
totalInches=INCHES_PER_FOOT*FEET*inches;

cout<<"the total number of inches="<<totalInches<<endl;

centimeters=CENTIMETERS_PER_INCH*totalInches;

cout<<"the number of centimeter="<<centimeters<<endl;

getch();
return 0;
}
OUTPUT
enter two integer

one feet and second inches=5 10
your enter number are 5 for feet and
second for 10
the total number of inches=600
the total number of centimeters=1524

write a program which accepts days as integer adn display total number of year ,months and days


#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int days,y,m,d;
cout<<"enter days=";
cin>>days;

y=days/365;
days=days%365;
m=days/30;
d=days%30;

cout<<"year="<<y<<endl
    <<"month="<<m<<endl
    <<"days="<<d<<endl;

getch();
return 0;
}
OUTPUT

enter days=390
year=1
month=0
days=25



write a program to accept a charecter and display its next charector.


#include<iostream.h>
#include<conio.h>
int main()
{
int radius;
float areaofcircle=0;

clrscr();
cout<<"radius of circle=";
cin>>radius;

areaofcircle=3.14*(radius*radius);

cout<<"area of circle="<<areaofcircle<<endl;

getch();
return 0;
}
OUTPUT
radius of circle=5
area of circle=78.5



write a program which accepts amount as integer and display total mumber of notes RS 500,RS 50,RS 20,RS 10,RS 5,RS 51.


#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int amount,R_500,R_100,R_50,R_20,R_10,R_5,R_1;

cout<<"enter amount";
cin>>amount;

R_500;
amount/500;
amount=amount%500;

R_100=amount/100;
amount=amount%100;

R_50=amount/50;
amount=amount%50;

R_20=amount/20;
amount%20;

R_10=amount/10;
amount=amount%10;

R_5=amount/5;
amount=amount%5;

R_1=amount;

cout<<"RS500="<<R_500<<endl
<<"RS100="<<R_100<<endl
<<"RS50="<<R_50<<endl
<<"RS20="<<R_20<<endl
<<"RS10="<<R_10<<endl
<<"RS5="<<R_5<<endl
<<"RS1="<<R_1<<endl;

getch();
return 0;
}
OUTPUT

enter amount=560
RS500=1
RS100=0
RS50=1
RS20=0
RS10=1
RS5=0
RS1=0

PREVIEW                           HOME                                    NEXT

Comments

Popular posts from this blog

Latest random post with thumbnail widget HTML / JAVASCRIPT

simple php program upload file in database