j
Showing posts with label CPP. Show all posts
Showing posts with label CPP. Show all posts

Saturday, 7 November 2015

Write a program that take valuse of a and b then enterchange their values without using extra variable

PROGRAM SOLUTION

#include<iostream.h>
#include<conio.h>
void mian()
{
clrscr();
int a,b;
cout<<"Enter the value of a and b :: ";
cin>>a>>b;
cout<<"The value of a before change :: "<<a<<endl;
cout<<"The value of b before change :: "<<b<<endl;
a=a+b;
b=a-b;
a=a-b;
cout<<"The value of a after change :: "<<a<<endl;
cout<<"The value of b after change :: "<<b<<endl;
getch();
}

OUTPUT

Write a program that take values of a and b than enterchange their values

Program Solution

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,temp;
cout<<"Enter the values a and b ::";
cin>>a>>b;
cout<<"The value of a before change :: "<<a<<endl;
cout<<"The value of b before change :: "<<b<<endl;
temp=a;
a=b;
b=temp;
cout<<"The value of a after change :: "<<a<<endl;
cout<<"The value of b after change :: "<<b<<endl;
getch();
}

Output

Write a program that take Radius and Height of cylinder and display area of Cylinder.....

#include<iostream.h>
#include<conio.h>
void main()
{
float a,pi;
int r,h;
cout<<"Enter radius of cylinder ::";
cin>>r;
cout<<"Enter height of cylinder ::";
cin>>h;
pi=3.142;
a=2*pi*r*(r+h);
cout<<a;
getch();
}

Write a program that take lenght, width and height from user and find the volume, there volume =length*width*height

Program Solution

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int len,wid,hei,v;
cout<<"Enter length ::";
cin>>len;
cout<<"Enter width ::";
cin>>wid;
cout<<"Enter heigth ::";
cin>>hei;
v=len*wid*hei;
cout<<"Valume is "<<v;
getch();
}

Output



Write a program that take five integer value and solve it 6*a*a-2*b*b+5*a*b+3*b*e*d

Program Solution

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e,res;
cout<<"Enter five integer value:"<<endl;
cin>>a>>b>>c>>d>>e;
res=6*a*a-2*b*b+5*a*b+3*b*e*d;
cout<<"The result is "<<res;
getch();
}

Output

 


Write a program that take two numbers from user and display its sum

Program Solution 

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
double sum;
cout<<"Enter two numbers:"<<endl;
cin>>a>>b;
sum=a+b;
cout<<"Sum of two fractional value is "<<sum<<endl;
getch();
}

 Output