0
What should i do in last line
#include <iostream> using namespace std; int main() { int num; cout<<"Institute Timer.\n"; cin>>num; while (num >= 0) { cout << "Number: " << num << endl; num = num -1; if(num==0){ cout<<"Cookover!"<<endl; } } return 0; } if you compile it, it will say (when you write 5) 5 4 3 2 1 cookover! 0 but i want this program to say 5 4 3 2 1 0 cookover! what should i do?
4 Answers
+ 11
Or you can do
if (num == -1)
//crappy fix tho.
+ 9
move cookover outside the loop?
+ 6
do:
while (num > 0) {
instead of:
while (num >= 0) {
(Line 9)
+ 1
You don't need the if loop. remove the if loop and close the while loop before cout << "cookover"
You are set!