This program reads four values a,b,c, and d from the terminal and evaluates the ratio of (a+b) to (c-d)
and prints the result, if c-d is not equal to zero.
#include <stdio.h>
void main()
{
int a,b,c,d;
float ratio;
printf("Enter four integer values\n");
scanf("%d %d %d %d",&a,&b,&c,&d);
if(c-d!=0)
{
ratio=(float)(a+b)/(float)(c-d);
printf("Ratio = %f\n",ratio);
}
getch();
}
and prints the result, if c-d is not equal to zero.
#include <stdio.h>
void main()
{
int a,b,c,d;
float ratio;
printf("Enter four integer values\n");
scanf("%d %d %d %d",&a,&b,&c,&d);
if(c-d!=0)
{
ratio=(float)(a+b)/(float)(c-d);
printf("Ratio = %f\n",ratio);
}
getch();
}
No comments:
Post a Comment