Monday 10 October 2011

10-10-2011 do-while loop (even odd)




/*program uses do-while loop and prints even numbers as they are entered but exits if an odd number is entered.*/

#include <stdio.h>
#include <conio.h>
int main()
{
    int num;
    do
    {
          scanf("%d",&num);
          if (num%2 !=1 )
                    printf("%d\n",num);
    }
    while (num %2 != 1);
    getche();
    return 0;
}

No comments:

Post a Comment