Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

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: 2855

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 using if statement.

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
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

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!