Pages

Wednesday, February 10, 2016

Example of nested if statement. Check: A is greater than B and C.

#include <stdio.h>
void main ()
{
int a, b, c;
  printf("Enter number A:");
  scanf("%d",&a);

  printf("Enter number B:");
  scanf("%d",&b);

  printf("Enter number C:");
  scanf("%d",&c);

  if( a > b )
  {
    if( a > c )
      printf("A is greater than B and C.");
  }
}
/* Output
Enter number A:5
Enter number B:4
Enter number C:2
A is greater than B and C.
*/

No comments:

Post a Comment