Print first 50 even or odd numbers by switch | Even & odd


// This is written by "Syed Ali Haider"
// Student of Havjery University
// Don't remove these line for legal use
// Upload on Let's programming by (CEO)
// For contact
// key_to_programming@yahoo.com

#include <iostream>
using namespace std;

void main (void)
{
       char option;

       cout<<"Press 'E' for even number\nPress 'O' for odd number"<<endl;
       cout<<"Please enter here: ";
       cin>>option;
       cout<<endl;

       switch (option)
       {// starting of switich statement
       case 'E':
       case 'e':

             {
                    for (int even=2; even<=50; even=even+2)
                    {
                           cout<<even<<" ";
                    }
                    break;
             }

       case 'O':
       case 'o':
             {
                    for (int odd=1; odd<=50; odd=odd+2)
                    {
                           cout<<odd<<" ";
                    }
                    break;
             }

       default:
             cout<<"You can only enter O / E"<<endl;

       } // ending of switch statment
      
       cout<<endl;
}
// This is written by "Syed Ali Haider"
// Student of Havjery University
// Don't remove these line for legal use
// Upload on Let's programming by (CEO)
// For contact
// key_to_programming@yahoo.com


Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System