Search:

Submit Article

# Program reads 4 values a, b, c, and d and evaluates the ratio of (a+b) to (c-d) and prints the result, if c-d is not equal to zero using if statement

Posted By: Aubrey Schmidt     Category: C Programming     Views: 9601

## Code for Program reads 4 values a, b, c, and d and evaluates the ratio of (a+b) to (c-d) and prints the result, if c-d is not equal to zero using if statement in C Programming

```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)  /* Execute statement block */
{
ratio = (float)(a+b)/(float)(c-d);
printf("Ratio = %f\n", ratio);
}
}

Output

Enter four integer values
12  23  34  45
Ratio = -3.181818

Enter four integer values
12  23  34  34
```
Share:

 Aubrey Schmidt author of Program reads 4 values a, b, c, and d and evaluates the ratio of (a+b) to (c-d) and prints the result, if c-d is not equal to zero using if statement is from Frankfurt, Germany. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!