Message from C, C++ discussions
November 2019
— Even more simpler
register unsigned last = 0u; for(register unsigned num = 0;;++num) {last+=num; if(num + last > 100) break; }
reinterpret_cast
For example
#include <stdio.h>
#include <math.h>
main ()
int S;
int V;
S, V = 0;
while (!S > 100)
V = V + 1;
S = S + V;
printf ("The number is %d", V)
— Can this be considered correct?
— Only I don't know where to put parenthesis
— After while
— After while() {}
— And after main() too
— #include <stdio.h>
#include <math.h>
void main ()
{
int S;
int V;
S=0,V = 0;
while (S <100)
{
V = V + 1;
S = S + V;
}
printf ("The number is %d", V);
}
Just a little edit. Might help
— Thank you so much! What's void main?
— Entry point in your executable program
— Another thing. On while(S>100) should I put the "!"?
— It's an unary operator so ,IT WILL only work with one operand.
Here you can easily do while(S<100)
Instead of while(!S>100)
So and so