Question

Given the following loop….             for (i = 14; i <= 20; i++)            cout <<...

Given the following loop….

            for (i = 14; i <= 20; i++)

           cout << i <<endl;

If i++ were changed to i-- a compile error would result. True OR False. explain

C++

Homework Answers

Answer #1

Solution

Answer

False

Explanation

There will be no compilation error but infinite loop occurs

for (i = 14; i <= 20; i++)

           cout << i <<endl;

it will give result

14

15

16

17

18

19

20

if you change

for (i = 14; i <= 20; i--)

           cout << i <<endl;

it will start print

14

13

12

11

..

it willl go infinite loop and it will print numbers negative numbers also

loop will never stop

But please note it will not give compilation error

but infinite loop occur

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
True or False? a. int i = 0; while(i <= 20); { i = i+5; cout...
True or False? a. int i = 0; while(i <= 20); { i = i+5; cout << i << " "; } The above loop is an infinite loop. for(int i =5; i>=1 ; i++) { cout << i << endl; } The above loop is an infinite loop.
Do While loop on C++ I need to program a do while loop in which the...
Do While loop on C++ I need to program a do while loop in which the user have to choose between option A,a, B,b or C,c. I need a do while loop that if other letter (different from options is choose) the loop print a cout saying "Invalid selection. Plese, enter the selection again.   I have one, but isn't working well int main() { char option; do { cout<<"Please choose one of the following options: "<<endl<<endl; cout<<"Option A - Julian...
(True or False) The following is an infinite loop. for(int i = 0; i < 5;...
(True or False) The following is an infinite loop. for(int i = 0; i < 5; --i) { cout << "Haha"; }
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop (instead of for). • The function takes a single integer n as a parameter • The function prints a series between 1 and that parameter, and also prints its result • The result is calculated by summing the numbers between 1 and n (inclusive). If a number is divisible by 5, its square gets added to the result instead. • The function does not...
Given the following program segment….             for (num = 10; num >= 1; num--)            cout...
Given the following program segment….             for (num = 10; num >= 1; num--)            cout << setw(3) << num; Write a while loop that will have the same output. C++
int main() { int item; inti; //cout << arr[i] << ";"; cin >> item; int *arr...
int main() { int item; inti; //cout << arr[i] << ";"; cin >> item; int *arr = new int[item]; // for (int x = 0; x < item; x++) // { // } for (int x = 0; x < item; x++) { cin >> arr[x]; if (x > 0) { InsertionSort(x + 1, arr); for (inti = 0; i < x + 1; i++) { cout << arr[i] << ";"; }cout << endl; } } return 0; } can...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity  ...
I'm having a warning in my visual studio 2019, Can anyone please solve this warning. Severity   Code   Description   Project   File   Line   Suppression State Warning   C6385   Reading invalid data from 'DynamicStack': the readable size is '(unsigned int)*28+4' bytes, but '56' bytes may be read.   Here is the C++ code were I'm having the warning. // Sstack.cpp #include "SStack.h" // Constructor SStack::SStack(int cap) : Capacity(cap), used(0) {    DynamicStack = new string[Capacity]; } // Copy Constructor SStack::SStack(const SStack& s) : Capacity(s.Capacity), used(s.used)...
For some reason I followed the steps in my project and I am getting the incorrect...
For some reason I followed the steps in my project and I am getting the incorrect output and when I am submitting it, it gives me compilation error. Printing empty array -- next line should be blank Testing append: Shouldn't crash! Should print 100 through 110 below, with 110 on a new line: 100 101 102 103 104 105 106 107 108 109 110 Checking capacity of new array: OK Append test #2: Should print 100 through 120 below, on...
For different input n, i.e., n = 1, n = 10, n = 20, write down...
For different input n, i.e., n = 1, n = 10, n = 20, write down the final value of counter for function1, function2, and function3. Explain the counter result through math calculation. #include <iostream> using namespace std; void function1(int n){ int count = 0; for(int x = 0; x < 12; x++){ cout<<"counter:"<< count++<<endl; } } void function2(int n){ int count = 0; for(int x = 0; x < n; x++){ cout<<"--- x="<<x<<"------"<<endl; for(int i =0; i < n;...
I'm writing a fairly simple program in C++ and i keep getting an error message when...
I'm writing a fairly simple program in C++ and i keep getting an error message when i try to compile it I don't see what I'm doing wrong if someone could look at this and point me in the right direction? #inlcude <iostream> using namespace std; int main() {    int length, width, area;       cout<<"This program calculates the area of a ";    cout<<"rectangle.\n";    cout<<"What is the length and width of the rectangle ";    cout<<"separated by...