Monday, August 16, 2021

Display All Odd and Even Numbers in C++

 A simple program that I wrote to display all odd and even numbers using C++ programming languages.

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 at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Program Listing

// Odd_Even_Numbers.cpp

// Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

// www.jakerpomperada.blogspot.com and www.jakerpomperada.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines

// Dev C++ Version 5.11



#include <iostream>


using namespace std;


int main()

{


//declare variables

    int number=0;

    int n=0;


    cout << "\n\n";

cout << "\tDisplay All Odd and Even Numbers in C++";

cout << "\n\n";

cout << "\tGive a Number : ";

cin >> n;

cout <<"\n";

// print odd numbers

    cout << "\tThe odd numbers are:";

    cout << "\n\n";

    cout << "\t";

    for (number=1; number<=n; number+=2)

    {

        cout << " " << number <<"";

    }


    cout << "\n\n";

// print even numbers

    cout << "\tThe even numbers are:";

    cout << "\n\n";

    cout << "\t";

    for (number=0; number<=n; number+=2)

    {

        cout << " " << number <<"";

    }


cout << "\n\n";

cout << "\tEnd of Program";

cout << "\n\n";

system("pause");

}


No comments:

Post a Comment