Wednesday, February 16, 2011

Managing Input and Output Operations

Write a program to read the values of x and y and print the results of the following expressions in one line:
(a) (x+y)/(x-y)           (b) (x+y)/2        (c) (x+y)(x-y)

#include
void main()
{
float x,y,a,b,c;
clrscr();
printf("Enter the value of x and y\n");
scanf("%f %f",&x,&y);
a=(x+y)/(x-y);
b=(x+y)/2;
c=(x+y)*(x-y);
printf("(x+y)/(x-y)= %f\n(x+y)/2= %f\n(x+y)*(x-y)= %f",a,b,c);
getch();
}

No comments:

Post a Comment