How should i take input from user

how should i apply loop for taking inputs from users when i dont know how many inputs user want to give

in eclipse it is showing no but here it is showing yes.

Try to create an infinite loop and break the loop whenever the condition for taking input is not satisfied. Think of ways to create an infinite loop, as a hint, use a while loop.
What is it showing yes or no for?

i am unable to get you. can you explore what are you saying

Sure. See, since you have to continuously take input until the sum of the inputs becomes negative, and you don’t know the number of inputs, you can keep a while loop like :

while(true){

}

And inside you can keep taking input and adding it to the sum as well as printing. As soon as the sum becomes negative, you can break this loop by putting a ‘break’ statement. You can use an ‘if’ condition for this. This is just one way of doing the question. You can also keep a variable like i = 0; and say while(i==0) and then not increment or decrement ‘i’ inside the loop and again use a break statement when sum becomes -ve.

I hope what I’m trying to say is clear, if not let me know!

can you tell me whats wrogn in that?

The link you have shared is the code of a different question…It has the code of pythagorean triplet question. Please share the correct question’s code so that I can help you

its not written anywhere it should be of type long

You don’t need to use long datatype. The ‘for’ loop that you have put inside the while loop is not required, you need to remove it. And you don’t have to print the sum, you have to print the input that you are taking. Here is the corrected code : https://ide.codingblocks.com/s/116581

Let me know if anything is unclear

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.