Home
Subjects
Textbook solutions
Create
Study sets, textbooks, questions
Log in
Sign up
Upgrade to remove ads
Only $35.99/year
Unit 5
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Looping
Terms in this set (30)
What will each of the following program segments display?
x = 1;
y = 1;
cout << x++ << " ";
NOT 1
Find the error in the following code that is attempting to add up five numbers. What is the line number that contains the error?
int val, count = 0, sum = 0;
cout << "I will add up 5 numbers. \n;
while (count < 5)
{
cout << "Enter a number: ";
cin >> val;
sum += val;
count--;
}
cout << "The sum of these numbers is " << sum;
Line 8 (count--;)
Find the error in the following code that is attempting to add up five numbers. What is the line number that contains the error?
int val, count = 0, sum = 0;
cout << "I will add up 5 numbers. \n";
while (count < 5)
{
cout << "Enter a number: ";
cin >> val;
sum += Val;
count++;
}
cout << "The sum of these numbers is " << sum;
Line 7 (sum += Val;)
What will each of the following program segments display?
x = 2;
y = x++;
cout << x << " ";
NOT 3
Find the error in the following code that is attempting to add up five numbers. What is the line number that contains the error?
int val, count = 0, sum = 0;
cout << "I will add up 5 numbers. \n";
while (count < 5)
{
cout << "Enter a number: ";
cout << val;
sum += val;
count ++;
}
cout << "The sum of these numbers is " << sum;
Line 6 (cout << val;)
What will each of the following program segments display?
x = 3;
y = x * x++;
cout << x << " ";
NOT 4
What will each of the following program segments display?
x = 99;
if (x++ < 100)
cout << "It is true!\n";
else
cout << "It is false!\n";
It is true!
What will each of the following program segments display?
x = 0;
y = x++;
cout << x << " ";
NOT 1
Which will each of the following program segments display?
x = 7;
y = x++;
cout << x << " ";
NOT 8
What will each of the following program segments display?
x = 6;
y = 4;
cout << x++ << " ";
NOT 6
Find the error in the following code that is attempting to add up five numbers. What is the line number that contains the error?
int val, count, sum = 0;
cout << "I will add up 5 numbers. \n";
while (count < 5)
{
cout << "Enter a number: ";
cin >> val;
sum += val;
count++;
}
cout << "The sum of these numbers is " << sum;
NOT 3
How many lines will the following while loop display?
int count = 1;
while (count < 5);
{
cout << " My favorite day is Sunday";
count = count + 1;
}
NOT 4
What will each of the following program segments display?
x = 2;
y = ++x;
cout << x << " ";
NOT 3
How many lines will the following while loop display?
int count = 0;
while ( count <= 5)
{
cout << "My favorite day is Sunday ";
count = count + 1;
}
6
What will each of the following program segments display?
x = 4;
y = 3 * x++;
cout << x << " ";
NOT 5
Other sets by this creator
Unit 3
4 terms
Unit 2
28 terms
Unit 1
62 terms
Verified questions
COMPUTER SCIENCE
Design a Java interface called Priority that has two methods: setPriority and getPriority. The interface should let us number a set of objects in the order of their importance. Design and implement a class called Task that implements the Priority interface. Create a driver class to use some Task objects.
COMPUTER SCIENCE
Use what you’ve learned about the binary numbering system to convert the following binary numbers to decimal: 1101 1000 101011
COMPUTER SCIENCE
Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period.
COMPUTER SCIENCE
Show that no compression scheme can expect to compress a file of randomly chosen 8-bit characters by even a single bit. (Hint: Compare the number of possible files with the number of possible encoded files.)
Other Quizlet sets
Causes of the Civil War (Boyd)
27 terms
MIS 3305 Final Exam
34 terms
BIO 211 - Final
512 terms
obe chap 14
72 terms