About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Friday, August 30, 2013

C program to read the values of x, y and z and print the results expressions in one line.

Problem Statement : Write a program to read the values of x, y and z and print the results of the following expressions in one line.

  1. (x+y+z) / (x-y-z)
  2. (x+y+z) / 3
  3. (x+y) * (x-y) * (y-z)
#include<stdio.h>
#include<conio.h>

void main()
{
int x,y,z;
float a,b,c;
clrscr();

printf("nEnter the values of x,y and z : ");
scanf("%d %d %d",&x,&y,&z);
a = (x+y+z) / (x-y-z);
b = (x+y+z) / 3;
c = (x+y) * (x-y) * (y-z);

printf("a = %fnb = %fnc = %f",a,b,c);
getch();
}
Output:
Enter the values of x,y and z : 1.1 2.5 5.5
a = -1.000000
b = 2010.000000
c = 27939.000000

No comments: