You sound incredibly lazy. Seeing as this is a trivial program, try it yourself first.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Replace ++x; with scanf("%d", &x); and your logic is reasonably sound. Otherwise it's broken because the loop will never end[1].
[1] It will end, but not in a well-defined way.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
but if i do it like in the number 2...is it also right?
No. Might I recommend dropping down a level and learning basic programming through pseudocode? Your C is just awful, and not understanding the the fundamentals won't help.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401