Thursday, October 18, 2012

Prog1 Final Exam Batch 2


Odd and Even Detection

Write a program that will ask a number and display whether it is odd or even.

            ENTER A NUMBER: 27
            IT IS ODD.
            ENTER A NUMBER: 4
            IT IS EVEN.
            ENTER A NUMBER: 24
            IT IS EVEN.
            ENTER A NUMBER: A
INVALID INPUT
            ENTER A NUMBER: 0
GOODBYE

The program will keep prompting the user for a number.

If the user enters an invalid input (e.g. a letter or a number with decimal value), it will print “INVALID INPUT”.

If the user will input 0, the program will print “GOODBYE”. Then, it will automatically exit.

0 comments:

Web Marketingdrive recovery software