Tuesday, 19 April 2011

Example program on if..else condition

/*    Two-way selection.
      */
#
include < stdio.h >

 int main(void) {
  // Local Declarations
  int a;
  int b;

  // Statements
  printf("Please enter two integers: ");
  scanf("%d%d", & a, & b);

  if (a <= b) {
   printf("%d <= %d\n", a, b);
  } else {
   printf("%d > %d\n", a, b);
  } //end a <= b if

  return 0;
 } // main

/*    Results:
Please enter two integers: 10 15
10 <= 15
*/



 Conditional statements
 



No comments:

Post a Comment