how to make a loop in the c++ program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

how to make a loop in the c++ program

I was given the task of making a C ++ program using a loop. I didn't really understand loop

22nd May 2019, 4:05 PM
dand
dand - avatar
12 Answers
+ 10
Maybe use do-while
22nd May 2019, 4:37 PM
dand
dand - avatar
+ 9
make the command in c ++ to determine odd numbers using the loop function
22nd May 2019, 4:30 PM
dand
dand - avatar
+ 8
yes,I mean how the loop works
22nd May 2019, 4:18 PM
dand
dand - avatar
+ 7
What is output
22nd May 2019, 4:41 PM
dand
dand - avatar
+ 6
You mean
22nd May 2019, 4:12 PM
dand
dand - avatar
+ 3
But it's just a few lines of code int x; cin >> x; if (x % 2 == 1) cout << "Odd"; else cout << "Even";
22nd May 2019, 4:39 PM
Airree
Airree - avatar
+ 2
You probably should use recursive functions
22nd May 2019, 4:09 PM
Airree
Airree - avatar
+ 2
If you input an odd number, it returns "Odd", if even, it returns "Even"
22nd May 2019, 4:42 PM
Airree
Airree - avatar
+ 2
loop is define as command which runs many times according to conditions you can create loops in many ways, cpp provide you many type of commands which helps to create a loop according to yaar condition. also you can create loop with the help of recursion recursion is the method in which function calls itself.
23rd May 2019, 1:40 AM
Ameer Wajid Ali
Ameer Wajid Ali - avatar
0
That depends on what you want
22nd May 2019, 4:13 PM
Airree
Airree - avatar
0
what is your task
22nd May 2019, 4:18 PM
Airree
Airree - avatar
0
I can't see how would you need loops for that
22nd May 2019, 4:33 PM
Airree
Airree - avatar