Saturday, May 7, 2016

Odd and Even Numbers in C++ using Structure

A simple program that I wrote a long time ago that will check if the give number is odd or even using structure in C++.

 Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <iomanip>

using namespace std;



struct odd {

int n;

  int odd_even() {

  if (n % 2 == 0)
        {
                 cout << n <<" Number is even!\n";
        }
        else
        {
                 cout << n << " Number is odd!\n";
        }
   return(n);

  }

};

main() {

    odd value;

   cout << "\t\t ODD and Even Number Determiner";
   cout << "\n\n";
   cout << "Enter a Number :";
   cin >> value.n;
   cout << "\n\n";
   cout << value.odd_even();
   cout << "\n\n";
   system("pause");


}


No comments:

Post a Comment