Monday, 3 October 2011

03-10-2011 Example of Usage of Conditional Operators


/*This program takes marks of student, uses conditional operators to check them and shows either he is pass or fail*/
#include<stdio.h>
#include<conio.h>
main()
{
      int numbers = 0;
      printf("Please enter marks: ");
      scanf("%d", &numbers);
      (numbers >= 60)? printf( "Pass") : printf("Fail");
      getche();
}
/*
is same as
        int numbers = 0;
      printf("Please enter marks: ");
      scanf("%d", &numbers);
      if (numbers >= 60)
         {
         printf("Pass");
         }
      else
          {
          printf("Fail");
          }
      getche();
      return 0;
     
      */


No comments:

Post a Comment