You are on page 1of 7

//1: Program to print sum of two values.

#include<iostream.h>

#include<conio.h>

int main()

clrscr();

int value1,value2,sum;

cout<<"Enter First Value:";

cin>>value1;

sum=value1+value2;

cout<<"The sum of given values is:";

cout<<sum;

return 0;

//2: Program to display ASCII code offf a character and vice versa

#include<iostream.h>

int main()

char ch='A'; //assign ASCII code for 'A' to ch


int num=ch; //store same code in an int

cout<< "The ASCII code for"<<ch<<"is"<<num<<"\n";

cout<<"Adding 1 to the character code\n";

ch=ch+1;

num=ch;

cout<<"The ASCII code for"<<ch<<"is"<<num<<"\n";

return 0;

//3: Program to calculate and display area of a circle with radious 6 cm.

#include<iostream.h>

int main()

float radious=6.0;

float area;

area=3.14159*radious*radious;

cout<<"Area of the circle is:"<<area;

return 0;

}
//4: Program(using a function) to accept a number and print its cube.

#include<iostream.h>

#include<stdlib.h>

float cube(float);

int main()

system("cls");

float num;

cout<<"Enter a number:";

cin>>num;

cout<<"\n"<<"The cube of"<<num<<"is"<<cube(num)<<"\n";

return 0;

float cube(float a)

return a*a*a;

//5: Program to inputs experience and age of a person.

#include<iostream.h>

int main()

{
int exper,age,salary;

cout<<"The person is experienced ?"<<"Enter 1 for yes, 0 for no :";

cin>>exper;

cout<<"\nEnter age of the person :";

cin>>age;

salary=(exper)?((age>35)?6000:(age>28)?4800:3000):2000;

cout<<"\n The salary of the person is"<<salary<<"\n";

return 0;

//6: The value of e is known to be 2.71828.... Using this value, write a program to
determine the value of the expression : 2-ye2y+4y Obtain value of y from user.

#include<iostream.h>

#include<math.h>

int main()

const double e=2.71828;

double result, y;

cout<<"Enter value of y:";

cin>>y;

result=2-y*exp(2*y)+Pow(4,y);
cout<<"The result of given expression is: "<<result;

return 0;

//7: Tempreture conversion program.

#include<iostream.h>

int main()

int choice;

double temp,conv_temp;

cout<<"Temperature Conversion Menu"<<"\n";

cout<<"1. Fahrenheit to celsius"<<"\n";

cout<<"2.Celsius to Fahrenheit"<<"\n";

cout<<"Enter your choice(1-2):";

cin>>choice;

if(choice==1)

cout<<"\n"<<"Enter temperature in Fahrenheit :";

cin>>temp;

conv_temp=(temp-32)/1.8;

cout<<"The temperature in Celsius is"<<conv_temp<<"\n";

}
else

cout<<"\n"<<"Enter temperature in Celsius:";

cin>>temp;

conv_temp=(1.8*temp)+32;

cout<<"The temperature in Fahrenheit is"<<conv_temp<<"\n";

return 0;

//8: Program to create the equivalent of four-function calculator.

#include<iostream.h>

int main()

char ch;

float a,b,result;

cout<<"Enter two number :";

cin>>a>>b;

cout<<"\n"<<"Enter the operator(+,-,*,/) :";

cin>>ch;

cout<<"\n";

if(ch=='+')
result=a+b;

else

if(ch=='-')

result=a-b;

else

if(ch=='*')

result=a*b;

else

if(ch=='/')

result=a/b;

else

cout<<"Wrong Operator \n";

cout<<"\n"<<"The calculated result is :"<<reult<<"\n";

return 0;

//9: Program to input a character and to print whether a given character is an

You might also like