1. Write a Program in C++ that print the Hello World.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
Cout <<"Hello World";
getch();
}
...................................................................................................................................................................
2. Write a Program for Find the Sum of Two Numbers.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
float a,b;
textbackground(9);
clrscr();
Cout<<"Enter The Two Number\n";
Cin>>a>>b;
float c=a+b;
Cout<<endl<<"The Sum of "<<a<<"and "<<b<<"is"<<c;
getch();
}
...................................................................................................................................................................
3. Write a program for find the Greatest of Three Numbers.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,c;
clrscr();
Cout<<"Enter The First Number";
cin>>a;
Cout<<"Enter the Second Number";
cin>>b;
Cout<<"Enter the Third Number";
cin>>c;
if(a>b)
{
if(a>c)
Cout<<"a is greatest";
else
Cout<<"c is greatest";
cin>>C>>a;
}
else
{
if(b>c)
Cout<<"b is greatest";
else
Cout<<"C is greatest";
}
getch();
}
...................................................................................................................................................................
4. Write a Program for perform the Substraction, Addition, Multiplication and Division of Two Numbers.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,ch,sum,sub,mult,div;
clrscr();
Cout<<"Enter the First Number";
cin>>a;
Cout<<"Enter the Second Number";
cin>>b;
sum=a+b;
sub=a-b;
mult=a*b;
div=a/b;
Cout<<"**************************************\n";
Cout<<"Press 1 : For Addition\n";
Cout<<"Press 2 : For Substraction\n";
Cout<<"Press 3 : For Multiplication\n";
Cout<<"Press 4 : For Division\n";
Cout<<"Enter Your Choice:";
cin>>ch;
Switch(ch)
{
Case 1 : Cout<<"Addition of Two Number="<<sum;
break;
Case 2 : Cout<<"Substraction of Two Number="<<sub;
break;
Case 3 : Cout<<"Multiplication of Two Number="<<mult;
break;
Case 4 : Cout<<"Division of Two Number="<<div;
break;
default : Cout<<"Sorry Wrong Choice";
}
getch();
}
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
Cout <<"Hello World";
getch();
}
...................................................................................................................................................................
2. Write a Program for Find the Sum of Two Numbers.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
float a,b;
textbackground(9);
clrscr();
Cout<<"Enter The Two Number\n";
Cin>>a>>b;
float c=a+b;
Cout<<endl<<"The Sum of "<<a<<"and "<<b<<"is"<<c;
getch();
}
...................................................................................................................................................................
3. Write a program for find the Greatest of Three Numbers.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,c;
clrscr();
Cout<<"Enter The First Number";
cin>>a;
Cout<<"Enter the Second Number";
cin>>b;
Cout<<"Enter the Third Number";
cin>>c;
if(a>b)
{
if(a>c)
Cout<<"a is greatest";
else
Cout<<"c is greatest";
cin>>C>>a;
}
else
{
if(b>c)
Cout<<"b is greatest";
else
Cout<<"C is greatest";
}
getch();
}
...................................................................................................................................................................
4. Write a Program for perform the Substraction, Addition, Multiplication and Division of Two Numbers.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,ch,sum,sub,mult,div;
clrscr();
Cout<<"Enter the First Number";
cin>>a;
Cout<<"Enter the Second Number";
cin>>b;
sum=a+b;
sub=a-b;
mult=a*b;
div=a/b;
Cout<<"**************************************\n";
Cout<<"Press 1 : For Addition\n";
Cout<<"Press 2 : For Substraction\n";
Cout<<"Press 3 : For Multiplication\n";
Cout<<"Press 4 : For Division\n";
Cout<<"Enter Your Choice:";
cin>>ch;
Switch(ch)
{
Case 1 : Cout<<"Addition of Two Number="<<sum;
break;
Case 2 : Cout<<"Substraction of Two Number="<<sub;
break;
Case 3 : Cout<<"Multiplication of Two Number="<<mult;
break;
Case 4 : Cout<<"Division of Two Number="<<div;
break;
default : Cout<<"Sorry Wrong Choice";
}
getch();
}
...................................................................................................................................................................
5. Write a Program for print the digits in Words from 1-10.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int num;
clrscr();
Cout<<"Enter the Number between 1-10:";
cin>>num;
if (num == 1)
Cout<<"One";
else if (num == 2)
Cout<<"Two";
else if (num == 3)
Cout<<"Three";
else if (num == 4)
Cout<<"Four";
else if (num == 5)
Cout<<"Five";
else if (num == 6)
Cout<<"Six";
else if (num == 7)
Cout<<"Seven";
else if (num == 8)
Cout<<"Eight";
else if (num == 9)
Cout<<"Nine";
else if (num == 10)
Cout<<"Ten";
else
Cout<<"Out of Range";
getch();
}
*********************************************************************************
0 comments:
Post a Comment