News15 mins ago
Can Someone Please Help Me With My C++ Homework
3 Answers
I have a simple problem in my textbook that I just couldn't understand. Since classes were cancelled, we didn't really get a chance to discuss it and I don't see any examples similar to it in the chapter.
Suppose that the input is 6 -2 4 9 -5 8. What is the output of the following code?
int num, count, temp = 1;
cin >> num;
for (count = 1; count > num;
}
cout
Suppose that the input is 6 -2 4 9 -5 8. What is the output of the following code?
int num, count, temp = 1;
cin >> num;
for (count = 1; count > num;
}
cout
Answers
Best Answer
No best answer has yet been selected by bernicevendeza. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.This is from my son. I hope it helps.
The code provided is not valid C++ syntax. I think I gather what the code is meant to do though.
The input isn't valid as an integer unless you put a + where the positive numbers are. Unless these are not one input but meant to be done sequentially.
It will go through the for loop while count < input, and increment at the end of the loop.
The cout doesn't have anything after it but I presume it is meant to display count which will be the same as the input number.
int num, count, temp = 1;
std::cin >> num;
for (count = 1; count < num; count++) {
}
std::cout
The code provided is not valid C++ syntax. I think I gather what the code is meant to do though.
The input isn't valid as an integer unless you put a + where the positive numbers are. Unless these are not one input but meant to be done sequentially.
It will go through the for loop while count < input, and increment at the end of the loop.
The cout doesn't have anything after it but I presume it is meant to display count which will be the same as the input number.
int num, count, temp = 1;
std::cin >> num;
for (count = 1; count < num; count++) {
}
std::cout