Problem:

Create a C + + program to determine whether a number is the user input is odd or even number.

Analysis:

To create C + + program that determines the odd or even number, we must first know how to distinguish between odd and even numbers. Examples of odd numbers are 1, 3, 5, 7, 9 and so on. Examples of even number is 2, 4, 6, 8 and so on. Before you can determine the odd and even numbers, you should know the rest of the division operator (MOD) / modulus

Division remainder operator yields the remainder quotient, for more details see the following example:

4 mod 2 0 (clear)
5 mod 2 1 (odd)
12 mod 4 0 (clear)
15 mod 2 1 (odd)


Program :
If created in C + + program, then the following is a C + + program to determine odd or even numbers.

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
clrscr();
int bil, sisa;
cout<<"Insert some value : "; cin>>bil;
sisa = bil % 2;
if(sisa == 0)
cout<<<" even number"< else cout<<<" odd number"< getch();

0 comments



Recent Entries