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...
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)...
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++
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...
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow...
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 40: 20 10 5 2 1 ..... my code: #include <iostream> using namespace std; int main() { int userNum; userNum = 40; /* Your solution goes here */ while (userNum != 1){ userNum = userNum/2; cout << userNum << " ";   } cout << endl; return 0; } ........ but as a result i...
C++ program that Create a struct called car that has the following data members (variables): -...
C++ program that Create a struct called car that has the following data members (variables): - Color //color of the car - Model //model name of the car - Year //year the car was made - isElectric //whether the car is electric (true) or not (false) - topSpeed //top speed of the car, can be a decimal. code i have done struct not working properly. #include <iostream> using namespace std; struct Car { string color; string model_number; int year_model; bool...
C++ Please and thank you. I will upvote Read the following problem, and answer questions. #include<iostream>...
C++ Please and thank you. I will upvote Read the following problem, and answer questions. #include<iostream> using namespace std; void shownumbers(int, int); int main() { int x, y; cout << "Enter first number : "; cin >> x; cout << "Enter second number : "; cin >> y; shownumbers(x, y); return 0; } void shownumbers(int a, int b) { bool flag; for (int i = a + 1; i <= b; i++) { flag = false; for (int j =...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT