A) Complete the following program: This program prints out TRUE if the user’s fi
ID: 3728108 • Letter: A
Question
A) Complete the following program:
This program prints out TRUE if the user’s first initial is between A and M, and the user’s zip code is 11234. Otherwise it prints out the user’s initial and the words
Good Luck (with the quotations).
#include<iostream>
using namespace std;
int main()
{
char initial;
int zip;
//use cin to input the initial and the zip code
//use an if statement
}
B) Trace the following code. Input to this code is: 4 15 11
bool checker = true;
int num,total=0;
do
{
cin>>num;
total+=num;
cout<<total<<endl;
if (total > 25)
checker = false;
}
while (checker);
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
char initial;
int zip;
//use cin to input the initial and the zip code
cin>>initial>>zip;
//use an if statement
if(initial>='A' && initial<='M' && zip==11234){
cout<<"TRUE"<<endl;
} else {
cout<<initial<<" Good Luck"<<endl;
}
}
Output:
B
11234
True
Question b
Answer:
The output of the given code is
4
19
30
do-while loop will terminate when checker is false. checker will get assigned false when total reaches greater than 25.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.