
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410 تمرين 9
Using a Sentinel Value to Control a while Loop
In this exercise, you use what you have learned about sentinel values. Study the following code, and then answer Questions.
int numToPrint, counter;cout ? "How many pages do you want to print? ";cin numToPrint;counter = 1;while(counter = numToPrint);{cout ? "Page Number " ? counter ? endl;counter++;}cout ? "Value of counter is " ? counter ? endl;
What is the problem with this code, and how can you fix it?
In this exercise, you use what you have learned about sentinel values. Study the following code, and then answer Questions.
int numToPrint, counter;cout ? "How many pages do you want to print? ";cin numToPrint;counter = 1;while(counter = numToPrint);{cout ? "Page Number " ? counter ? endl;counter++;}cout ? "Value of counter is " ? counter ? endl;
What is the problem with this code, and how can you fix it?
التوضيح
" While " loop:
The "while" loop is a c...
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
لماذا لم يعجبك هذا التمرين؟
أخرى 8 أحرف كحد أدنى و 255 حرفاً كحد أقصى
حرف 255