Odd-Even Program C++

Topics: Programming language / Pages: 2 (311 words) / Published: Jan 17th, 2013
LYCEUM OF THE PHILIPPINES UNIVERSITY
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

You May Also Find These Documents Helpful

  • Even and Odd Functions
  • c ++ program
  • C++ Programs
  • C Program
  • C Program
  • C Program
  • 89s52 C Program
  • Gauss Program on C++
  • Pythagorean Theorem and C++ Program
  • Simple Program for Student C++