100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COSC 1436 C++ Exam Study Questions and Answers $12.49   Add to cart

Exam (elaborations)

COSC 1436 C++ Exam Study Questions and Answers

 0 view  0 purchase
  • Course
  • Cosc
  • Institution
  • Cosc

COSC 1436 C++ Exam Study Questions and Answers Given an integer variable strawsOnCamel, write a statement that uses the auto-increment operator to increase the value of that variable by 1. - ANSWER-strawsOnCamel++; Given an integer variable timer, write a statement that uses the auto-decrement ...

[Show more]

Preview 3 out of 21  pages

  • November 3, 2024
  • 21
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Cosc
  • Cosc
avatar-seller
KaylinHoffman
Copyright © KAYLIN 2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED FIRST PUBLISH NOVEMBER, 2024




COSC 1436 C++ Exam Study Questions

and Answers


Given an integer variable strawsOnCamel, write a statement that uses the auto-increment operator to

increase the value of that variable by 1. - ANSWER✔✔-strawsOnCamel++;


Given an integer variable timer, write a statement that uses the auto-decrement operator to decrease

the value of that variable by 1. - ANSWER✔✔-timer--;


Consider this code: "int v = 20; --v; cout << v++;". What value is printed, what value is v left with? -

ANSWER✔✔-19 is printed, v ends up with 20


Consider this code: "int s = 20; int t = s++ + --s;". What are the values of s and t? - ANSWER✔✔-s is 20

and t cannot be determined


Given an int variable k that has already been declared, use a while loop to print a single line consisting of

97 asterisks. Use no variables other than k. - ANSWER✔✔-1. while (k<97)


2. {


3. cout<<"*";


4. k++;}



Copyright © Stuvia International BV 2010-2024 Page 1/21

, Copyright © KAYLIN 2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED FIRST PUBLISH NOVEMBER, 2024




Given an int variable n that has already been declared and initialized to a positive value, and another int

variable j that has already been declared, use a while loop to print a single line consisting of n asterisks.

Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j. - ANSWER✔✔-1.

j=n;


2. while(j>0){


3. cout<<"*";


4. j--;


5. }


Given a string variable s that has already been declared, write some code that repeatedly reads a value

from standard input into s until at last a "Y" or "y"or "N" or "n" has been entered. - ANSWER✔✔-1. while

((s!="Y"&&s!="y"&&s!="N"&&s!="n"))


2. {


3. cin>>s;


4. }


Given an int variable n that has already been declared, write some code that repeatedly reads a value

into n until at last a number between 1 and 10 (inclusive) has been entered. - ANSWER✔✔-1.

while(n>10||n<1){


2. cin>>n;

Copyright © Stuvia International BV 2010-2024 Page 2/21

, Copyright © KAYLIN 2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED FIRST PUBLISH NOVEMBER, 2024




3. }


Given int variables k and total that have already been declared, use a do...while loop to compute the

sum of the squares of the first 50 counting numbers, and store this value in total. Thus your code should

put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables other than k and total. -

ANSWER✔✔-1. total=0;


2. k=1;


3. do{


4. total+=k*k;


5. k++;


6. }while(k<=50);


Given an int variable n that has already been declared and initialized to a positive value, and another int

variable j that has already been declared, use a do...while loop to print a single line consisting of n

asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j. -

ANSWER✔✔-1. j=1;


2. do{


3. cout<<"*";


4. j++;



Copyright © Stuvia International BV 2010-2024 Page 3/21

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller KaylinHoffman. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

83637 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.49
  • (0)
  Add to cart