Saturday, March 19, 2011

If and Else

Write a program that will read an integer number from the user.The program will examine whether it is an even number or odd number.

include <stdio.h>
include <conio.h>
   void main ( )
{
   clescr ( );
   int number 1, number 2, R;
   print f ("please enter two numbers");
   scan f ("%d%d",& number 1,& number 2);
   R = number 1%2;
   if (R= = 0)
   print f ("%d is an even number ", number 1);
   if (R= = 1)
   else
   print f ("%d is an odd number", number 1);
   print f ("n");
   getch ( );
}

   R = number 2%2;
   if (R= = 0);
   print f ("%d is an even number ". number 2);
   else
   print f (%d is an odd number ". number);
   print f ("/n");
   getch ( );
}

Program will input the total mark of a student.The program will then perform certain logical test and will print message depending on the test result.

include <stdio.h>
include <conio.h>
   void main ( );
{
   clrscr ( );
   int number ;
   print f ("Enter total mark of a student;");
   scan f ("%d", & number);
   if (number > = 330)
   if (number > = 450)
   if (number > = 600)
   print f ("First division");
   else
   print f ("Second division");
   else
   print f ("Third division");
   getch ( );
}

No comments:

Post a Comment