Can you tell me how i create c++ program to read a sequence of nonnegative integers from the user ending with a negative integer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you tell me how i create c++ program to read a sequence of nonnegative integers from the user ending with a negative integer

Problem in creating a code in c++

19th May 2022, 1:08 PM
Hadeel Hesham
1 Answer
+ 3
You could use a do-while loop and keep iterating 'till you find the negative number. Like so: https://code.sololearn.com/cUmY7zJ7Vhgz EDIT: If you need to store all the values you may want to look at dynamic arrays or std::vector.
19th May 2022, 1:13 PM
Maz
Maz - avatar