QuestionQuestion

Transcribed TextTranscribed Text

1) In C++ when a relational expression is false, it has the value - A) 1 B) 0 C)-1 D) "0" E) of any negative number 2) What are the outputs of the following statements (Assume that the statements are embedded in a correct program) string str1="ASU"; string str2="ASUT Tempe"; string str3="AsU"; cout<1 cout<2 couteistri.compare(str3); 3 4 0 the outputis 0. <0 the output is less than 0. >0 : the outputi is grater than 0. H 1:>0 2:>0 3:>0 4:>0 1:>0 2:<0 3:>0 4:0 1:<0 2:>0 3:<0 4:>0 1:0 2:0 3:<0 4:>0 3) What are the outputs of following statements (assume that all statements are correct and embedded in a correct program)? cout 1 cout << (!(7 > 6)) <2 cout<< (2*3==&&!(1>2)} <3 cout<< ( ((2*3==6&&1>2)) <4 1:1 (True) 2:0 (False) 3: 1 (True) 4: 1 (True) 1:1 (True) 2:0 (False) 3:0 (False) 4:1 (True) 1:1 (True) 2:1 (True) 3: 0 (False) 4:0 (False) 1:0 (False) 2:0 (False) 3:0 (False) 4:0 (False) 4) Whatwill the following expression evaluate to? !(>>>7||3==4) o A) B)-1 C) 6 D) true E) None of the above5) What are the outputs of following statements (assume that all statements are correct and embedded in a correct program)? char char1 = "a"; char char2 = "A"; cout<< (char1<char2);-- cout<< islower(char1);---- 1:0 (False) 2:0 (False) 1:0 (False) 2: 1 (True) 1: 1 (True) 2:0 (False) a 1: 1 (True) 2: 1 (True) 1) After the execution of the following code, what will be the value of num if the input value is 5? cin num; if (num > 0) num = num + 10; else if (num > 5) num = num + 15; A) 0 B) 5 C) 10 0 D)15 E)20 </char2);-- 2) Suppose X and y are int variables. Consider the following statements. if (x > 5) y = 1; else if (x < 5) { if (x < 3) y =2; else y=3; } else y = 4; What is the value of y if X = 4? A) 1 B) 2 C) 3 D) 4 E)63) the followiting Numbre at Discourt 5-10 10% 11-26 35% 21-30 20% 31 DE 25% The Das code asgment the prampta the iner - the number al and then the diccount Annuma that the in # number at is than 5 For # the - wrifer 15 then your coda should outpat 15% Plesse seluct the statements A 8. o int ( aux diomble discaust ast├ęts a neturn # stas * SK a A.K * 01, A BX * 115 jelas - C N * 02 . 9.25 discouncia 10 LA "- 10 - 20 . 78 RC . 30 1) What is the output of the following code fragment if the input value is 4? int num; int alpha = 10; cin >> num; switch (num) { case 3: alpha++ break; case 4: case 6: alpha = alpha + 3; case 8: alpha = alpha + 4; break; default: alpha = alpha + 5; } cout<<alpha; A) 13 B) 17 C) 14 D)22 E) 10 2) What is the output of the following code if the input is char C; cin>>c; switch(c){ case "+': cout<<" \n addition operation performed"; case *** cout<<" in multiplication operation performed"; break; case '-: cout<<" \n subtraction operation performed"; break; case '% cout<<" \n mod operation performed"; break; default: cout<<" \n invalid operator"; } A) addition operation performed multiplication operation performed B) multiplication operation performed C) addution operation performed D) invalid operator E) Error </alpha; 3) Which code is the re-write the following code segment using switch-case statement? We assume that all variables are already defined. int choice; choice = scan.nextint(); l/input the choice number and store as integer. // Respond to the user's menu selection. if (choice == 1){ cout<<"For how many months? "<<endl; months = scan.nextint(); charges =months * ADULT; cout<<"Thetotal charges are $"<< charges<<endl; } else if(choice==2){ cout<<"For howmanymonths?"<<endl; months = scan.nextint(); harges =months* CHILD; cout<<"Thetotal chargesare $"<< charges<<endl; } else if (choice == 3){ cout<<"For howmany months?"<<endl; months = scan.nextint(); charges =months*SENIOR; cout<<"The total charges are $"<< charges<<endl; } else if (choice == 4){ cout<<"Program ending."<<endl; } else { cout<<"The valid choices are 1 through 4. Run the"<<endl; cout<<"program again and select one of those. "<<endl; } 1.jnt choice; choice = scan.nextint(); Il Respond to the user's menu selection. switch(choice){ case 1: cout<<"For how many months? "<<endl; months = scan.nextint(); charges = months ADULT; cout<<"The total charges are $"<< charges<<endl; case 2: cout<<"For how many months? "<<endl; months =scan.nextint(); charges = months CHILD: cout<<"The total charges are $"<< charges<<endl; case 3: cout<<"For how many months? "<<endl; months =scan.nextint(); charges = months SENIOR; cout<<"The total charges are $"<< charges<<endl; case 4: cout<<"Programending."<<endl; default: cout<<"The valid choices are 1 through 4. Run the"<<endl; cout<<"program again and select one of those." "<<endl; } </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; 2. int choice; choice = scan.nextint(); II Respond to the user's menu selection. switch(choice){ case 1: cout<<"For how many months? "<<endl; months = scan.nextint(); charges = months * ADULT; cout<<"The total charges are $"<< charges<<endl; break; case 2: cout<<"For howmanymonths? "<<endl; months = scan.nextint(); charges = months * CHILD; cout<<"The total charges are $"<< charges<<endl; break; case 3: cout<<"For howmany months?"<<endl; months =scan.nextint(); charges = months * SENIOR; cout<<"The total charges are $"<< charges<<endl; break; case 4: cout<<"Programending."<<endl; break; default: cout<<"The valid choices are 1 through 4. Run the"<<endl; cout<<"program again and select one of those."<<endl; break; } 3. int choice; choice = scan.nextint(); Il Respond to the user's menu selection. switch(choice){ case '1': cout<<"For how many months? "<<endl; months = scan.nextInt(); charges = months * ADULT; cout<<"The total charges are $"<< charges<<endl; break; case "2": cout<<"For howmanymonths? "<<endl; months = scan.nextint(); charges = months CHILD; cout<<"Th total charges are $"<< charges<<endl; break; case 33: cout<<"For howmany months?"<<endl; months =scan.nextint(); charges = months * SENIOR; cout<<"The total charges are $"<< charges<<endl; break; case '4": cout<<"Program ending. "<<endl; break; default: cout<<"The valid choices are 1 through 4. Run the"<<endl; cout<<"program again and select one of those." '<<endl; break; } </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; </endl; 4. int choice; choice = scan.nextint(); Il Respond to the user's menu selection. switch (choice){ if(case 1): cout<<"For how many months? '<<<endl; months = scan.nextInt(); charges = months * ADULT; cout<<"The total charges are $"<< charges<<endl; break; if(case) 2): cout<<"For how many months? "<<endl; months = scan.nextint(); charges = months * CHILD; cout<<"The total charges are $"<<charges<<endl break; if(case 3): cout<<"For how many months? "<<endl; months = scan.nextint(); charges = months SENIOR; cout<<"The total charges are $"<<charges<<endl; break; if(case 4): cout<<"Programending."<<endl; break; else: cout<<"The valid choices are 1 through 4. Run the"<<endl; cout<<"program again and select one of those. "<<endl; break; } </endl; </endl; </endl; </charges<<endl; </endl; </charges<<endl </endl; </endl; </endl;

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

1. B p152
2.
1 < 0
2 > 0...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$23.00 $11.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats