Make an Age Data Entry Program in Cpp 2022
Make an Age Data Entry Program in Cpp 2022
//.......Mymixindia.com........... //.......Age Data Entry Program in Cpp 2022...... #include<iostream> using namespace std; int main() { int age; //....initilizing the age variable...... cout<<"\nWelcome to Data Entry Software \n"; cout<<"\n---------____________________DES_______________________________-------------------------\n"; cout<<"Only the age which is 18 above will be enter in this software \n"; TOP: //.....using the lable for goto statement to jump over the section..... cout<<"\nEnter the age \n"; cin>>age; try { if (age >= 18) { cout << "\nAccess granted - Data Entered\n"; } else { throw (age); } } catch (int myNum) { cout << "Access denied - You must be at least 18 years old.\n"; cout << "Age is: " << myNum; cout << "\n Data Not Entered\n"; } char choice = 'N'; cout<<"\n Do you want to continue \n"; cin>>choice; if((choice=='Y')||(choice=='y')) { goto TOP; } cout<<"Bye Bye"; return 0; }
The output of the above program
Welcome to Data Entry Software ---------____________________DES_______________________________------------------------- Only the age which is 18 above will be enter in this software Enter the age 23 Access granted - Data Entered Do you want to continue y Enter the age 18 Access granted - Data Entered Do you want to continue y Enter the age 34 Access granted - Data Entered Do you want to continue y Enter the age 100 Access granted - Data Entered Do you want to continue y Enter the age 12 Access denied - You must be at least 18 years old. Age is: 12 Data Not Entered Do you want to continue y Enter the age 1 Access denied - You must be at least 18 years old. Age is: 1 Data Not Entered Do you want to continue y Enter the age 25 Access granted - Data Entered Do you want to continue y Enter the age 27 Access granted - Data Entered Do you want to continue y Enter the age 2 Access denied - You must be at least 18 years old. Age is: 2 Data Not Entered Do you want to continue y Enter the age 100 Access granted - Data Entered Do you want to continue n Bye Bye
Related Posts:
Pointer Program with Aaary and Function in Cpp 2022
Program to Print Prime Number in CPP 2020
5 Namespace Program in C++ 2022