Saturday, December 6, 2014

Odd and Even Number Using Function in C++

In this article I would like to share with you how to write a function that will check if the number being given by our user is odd or even number in C++. The code is very simple and very easy to follow. I hope you will find my useful in your quest in learning C++ as your primary programming language.

If you have some questions regarding about my work in C++ please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines can reach me through my mobile number 09173084360 and 09993969756.



Sample Output of Our Program

Program Listing

#include <iostream>

using namespace std;

int odd_even(int value);

int odd_even(int value)
{
    if (value %2 == 0 ) 
    {
        cout << "The number is " << value << " Even Number.";
     }
    else 
    {
        cout << "The number is " << value << " Odd Number.";
     }
    cout << "\n\n";
    system("pause");
  
}


main()
{
      int number=0;
      
      cout << "Enter a Number : ";
      cin >> number;
      odd_even(number);
}     
      

No comments:

Post a Comment