Message from C, C++ discussions

November 2019

— Kool

— 

Need help.

"Write a program that shows, summing positive integers numbers (1+2+3...+...), what is the number you have to arrive to so their sum is bigger than 100"

— What I mean, is that I need to write a program in C. Now, after defining variables, what do I have to do? A "for" cicle? Or is it better a while cicle?

Message permanent page

— I would like to help you but can you please explain more in detail what your program should do?

— Yeah. This program should find what is the last number to sum to the sequence of positive integers so the final sum is > 100

Message permanent page

— Alright

— Just use a while loop

— How can I write highlighted code here?

— ``` code and the also 3x`

— Ok thanks

— What about

register unsigned num = 0u, last = 0u; for(;;) { ++last; num+=last; if(num + last > 100) { num = last; break; } }

Message permanent page

— Then num should be the last number