Write a program that used to compute the following after reading a value of x.
1. Y = (x2+2x-1)/5 if x<0
2. Y = (x-3) if x=0
3. Y = (x-14) if x>0
Program:
#include<stdio.h>
main(){
float x, y;
printf("Enter vlaue of X = ");
scanf("%f", &x);
if(x>0)
y=x-14;
else if(x==0)
y=x-3;
else
y=(x*x+2*x-1)/5;
printf("Y = %.f", y);
}
1. Y = (x2+2x-1)/5 if x<0
2. Y = (x-3) if x=0
3. Y = (x-14) if x>0
Program:
#include<stdio.h>
main(){
float x, y;
printf("Enter vlaue of X = ");
scanf("%f", &x);
if(x>0)
y=x-14;
else if(x==0)
y=x-3;
else
y=(x*x+2*x-1)/5;
printf("Y = %.f", y);
}