Sunday, March 13, 2022

Odd and Even Numbers Using Functions in C++

 A simple program that will ask the user how many items to process and then it will accept a series of an integer numbers and then our program will list down the even and odd numbers using functions in C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

Thank you very much for your support.





Program Listing

// Written By: Mr. Jake R. Pomperada, MAED-IT

// Date : November 21, 2010 Sunday

// Tool : C++



#include <iostream>


using namespace std;


// Global Variables


int a=0,r=0,data=0,b=0;

int values[10];



void get_data();

void display_even();

void display_odd();



void get_data(void)

{

     cout << "\tOdd and Even Numbers Using Functions in C++";

     cout << "\n\n";

     cout << "How Many Numbers : ";

     cin >> data;

     cout << "\n";

        for (b=1; b <= data; b++)

            {

            cout << "Enter Item No. "

                  << b <<  " :";

            cin >> b[values];

          }

}



void display_even(void)

{


    cout << "\n\n";

    cout << "List of Even Numbers : ";

    cout << "\n\n";

        for (a=1; a<=data; a++) {

            r = a[values] % 2;

            if (r ==0) {

                cout << " " <<a[values]

                << " ";

         }


     }

}



void display_odd(void)

 {

    cout << "\n\n";

    cout << "List of Odd Numbers : ";

      cout << "\n\n";

     for (a=1; a<=data; a++) {

         r = a[values] % 2;

         if (r !=0) {

          cout << " " <<a[values]

            << " ";

         }

     }

 }

 main() {


     get_data();

     display_even();

     display_odd();

     cout << "\n\n";

     system("pause");

 }



No comments:

Post a Comment