j
Showing posts with label C Language. Show all posts
Showing posts with label C Language. 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<stdio.h>
#include<conio.h>
void mian()
{
clrscr();
int a,b;
printf("Enter the value of a and b :: ");
scanf("%d%d",&a,&b);
printf("The value of a before change :: %d\n",a);
printf("The value of b before change :: %d\n",b);
a=a+b;
b=a-b;
a=a-b;
printf("The value of a after change :: %d\n",a);
printf("The value of b after change :: %d\n",b);
getch();
}


OUTPUT

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

Program Solution

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,temp;
printf("Enter the values a and b ::");
cin>>a>>b;
printf("The value of a before change :: %d\n",a);
printf("The value of b before change :: %d\n"b);
temp=a;
a=b;
b=temp;
printf("The value of a after change :: %d\n",a);
printf("The value of b after change :: %d",b);
getch();
}

Output

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

#include<stdio.h>
#include<conio.h>
void main()
{
float a,pi;
int r,h;
printf("Enter radius of cylinder ::");
scanf("%d",&r);
printf("Enter height of cylinder ::");
scanf("%d",&h);
pi=3.142;
a=2*pi*r*(r+h);
scanf(" Area of cylinder is ",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;
printf("Enter length ::");
scanf("%d",&len);
printf("Enter width ::");
scanf("%d",&wid);
printf("Enter heigth ::");
scanf("%d",&hei);
v=len*wid*hei;
printf("Valume is %d",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;
printf("Enter five integer value:");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
res=6*a*a-2*b*b+5*a*b+3*b*e*d;
printf("The result is %d");
getch();
}

Output

 


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

Program Solution 

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
double sum;
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
sum=a+b;
printf("Sum of two fractional value is %d",sum);
getch();
}

 Output