Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PART V Write a C++ program to prompt the user to enter the following selection.

ID: 3734313 • Letter: P

Question

PART V Write a C++ program to prompt the user to enter the following selection. If the user enters 1 (by pressing "1") then your program has to print all even numbers from 0 to 100 (inclusive). If the user enters 2 (by pressing "2") then your program should prompt the user to enter the first character of his/her first, middle, and last name and also four digit student I.D. number and print them as follows. If the user enters any other choice (number), you should terminate the program.

Sample output: ABC 1212

Explanation / Answer

#include <iostream>

using namespace std;

int main ( )

{
int n;
cout<<"Enter the options (1 or 2): "<<endl;
cin >> n;
if(n == 1) {
cout<<"Even numbers from 0 t 100: "<<endl;
for(int i=0;i<=100;i++) {
if(i % 2 == 0) {
cout<<i<<" ";
}
}
cout<<endl;
} else if(n == 2) {
string name;
int id;
cout<<"Enter the first character of his/her first, middle, and last name: "<<endl;
cin >> name;
cout<<"Enter the student id: "<<endl;
cin >> id;
cout<<name<<" "<<id<<endl;
}

return 0;

}

Output:

Enter the options (1 or 2): 1
Even numbers from 0 t 100:
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100

Enter the options (1 or 2): 2
Enter the first character of his/her first, middle, and last name: ABC
Enter the student id: 1212
ABC 1212