Write a C program to read the values of x and y and print the results of the following expressions in one line:
i. (x + y) / (x - y)
ii. (x + y)(x - y)
Program Code:
i. (x + y) / (x - y)
#include<stdio.h>
void main()
{
int x,y,A,B;
float Result;
printf("Enter the values of x,y\n");
scanf("%d %d " ,&x, &y);
A=(x+y);
B=(x-y);
Result=A/B ;
printf("%f", Result);
}
ii. (x + y)(x - y)
#include<stdio.h>
void main()
{
int x,y,A,B;
float Result;
printf("Enter the values of x,y\n");
scanf("%d %d " ,&x, &y);
A=(x+y);
B=(x-y);
Result=A*B ;
printf("%f", Result);
}
Post A Comment:
0 comments: