CAVITE CAMPUS
COLLEGE OF ENGINEERING AND COMPUTER STUDIES
DEPARTMENT OF COMPUTER STUDIES
LABORATORY ACTIVITY 3
ODD-EVEN NUMBER IN TURBO C
RATINGS
LIA G. BANDAHALA 2011 - 11502
MR. IVAN JAMES FERMANEJO
INSTRUCTOR
I. Aim : * Write a Program to determine whether input number is ODD or EVEN. * Proper demonstration the use of Conditional Statements and Control Statements. II. Tools/Apparatus : Turbo C
III. Procedure :
A. Common Procedure * Enter the number. Make the coding that if the entered number is ODD then display the message the “Number is odd”, else display that “Number is even”. B. Standard Procedure * Analysing the problem * Designing the solution * Flowchart START
int num;
if(num %2 ==0)
TRUE FALSE
printf(“%d is an EVEN number”, num);
printf(“%d is an ODD number”, num);
END
C. Implementing the Solution * Writing the code * * #include<stdio.h> * #include<process.h> * #include<conio.h> * * main(){ * * int num; * int letter; * * clrscr(); * * start: * printf("\nEnter a number: "); * scanf("%d", &num); * * if(num%2 == 0){ * printf("%d", num); * printf(" is an EVEN number!"); * } * else{ * printf("%d", num); * printf(" is an ODD number!"); * } * * printf("\n*************\n"); * printf("Enter again? [y][n]\t"); * scanf("%s", &letter); * * if(letter == 'y'){ * goto start; * } * else if(letter == 'n'){ * exit(0); * } * else{ * printf("\nInvalid Input!"); * printf("\nThank you! Bye!"); * } * * getch(); * return 0; * * }
* Compiling/Debugging the code
IV. Conclusion
In creating a program that would accept a number and determines if the number is an ODD or