Voter Validation Program in C++ || Switch Statement || C++ || Turbo C++

In this, we are going to see the topic of Switch case in C++.

This is a program of Switch Case in which we are going to verify that the voter can apply for Voter Id Card or not.

The code given below can be used for TURBO C++ Compiler:-

#include<iostream.h>
#include<conio.h>

void main()
{
    clrscr();
    cout<<"\n **** This Program is of Switch Case **** \n";
    int voter_age;
    cout<<"Is your age is 18- or 18+ or 18 ??\n";
    cout<<"For 18- press 1\n";
    cout<<"For 18+ press 2\n";
    cout<<"For 18 press 3\n";
    cin>>voter_age;

    switch(voter_age)
    {
        case 1: 
            cout<<"oohh!! Your age is below 18 \n";
            cout<<"So you cannot apply for Voter Id card\n";
            cout<<"Wait till you complete your 18 years age\n";
            break;
        
        case 2: 
            cout<<"Yeeah!! Your age is above 18 \n";
            cout<<"So you can apply for Voter Id card\n";
            break;

        case 3: 
            cout<<"Yeeah!! Your age is 18 \n";
            cout<<"So you can also apply for Voter Id card\n";
            break;

        default:
            cout<<"Oops!! Your input is not accepted.\n";
            cout<<"Please read the instructions carefully\n";
            break;
    }
    cout<<"Thank You !!";

    getch();
}

    
    

The code given below can be used for g++/gcc Compiler:-

#include<iostream>
using namespace std;

int main()
{
    cout<<"\n **** This Program is of Switch Case **** \n";
    int voter_age;
    cout<<"Is your age is 18- or 18+ or 18 ??\n";
    cout<<"For 18- press 1\n";
    cout<<"For 18+ press 2\n";
    cout<<"For 18 press 3\n";
    cin>>voter_age;

    switch(voter_age)
    {
        case 1: 
            cout<<"oohh!! Your age is below 18 \n";
            cout<<"So you cannot apply for Voter Id card\n";
            cout<<"Wait till you complete your 18 years age\n";
            break;
        
        case 2: 
            cout<<"Yeeah!! Your age is above 18 \n";
            cout<<"So you can apply for Voter Id card\n";
            break;

        case 3: 
            cout<<"Yeeah!! Your age is 18 \n";
            cout<<"So you can also apply for Voter Id card\n";
            break;

        default:
            cout<<"Oops!! Your input is not accepted.\n";
            cout<<"Please read the instructions carefully\n";
            break;
    }
    cout<<"Thank You !!";

    return 0;
}

    
    
#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post