how to not use loop but make it run please help? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to not use loop but make it run please help?

here is the code: #include <iostream> using namespace std; loop: int num4 = 0; if (num4 < 6) { num4++; cout << "\nNumber: " << num4; goto loop; } return 1; }

27th Jul 2018, 2:52 PM
Faheem Ahmad
Faheem Ahmad - avatar
3 Answers
+ 2
you should declare num4 variable as static https://code.sololearn.com/co0PKqKeN66A/#cpp
27th Jul 2018, 4:47 PM
MO ELomari
+ 1
#include <iostream> using namespace std; int main() { int num4 = 0; while(num4 < 6) { num4++; cout << "\nNumber: " << num4; } return 0; }
27th Jul 2018, 3:42 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
if you don't want loop as label, use code posted by me... if you don't want to use for etc loop, use code posted by Mohamed ELomari.. If you don't wanna use both labels and loops, update code of Mohamad ELomari with recursive function ...
27th Jul 2018, 5:31 PM
Ketan Lalcheta
Ketan Lalcheta - avatar