7
Make a program in C++ that displays on the screen the numbers from 1 until 1000, counting with these two, but without using the semicolon.
I already made a sketch here but I have to choose between appear the 1 or 1000.
To top it off, my code:
#include <iostream>
int main(int x = 0) {
while (x <= 1000 && std::cout << x++ << std::endl) {}
}
Why doesn’t he show the number 1
? Guys, here, for example; https://ideone.com/4663hX, the output is correct. Could someone explain to me why g++ display from the 2
?
Okay. This I read. And what do you try? Why without the semicolon? What’s the real problem? Is this some kind of codegolf or is it a homework assignment? Explain better.
– Guilherme Bernal
It is a challenge for the staff. There is no real problem.
– HiHello
This question is being discussed at the goal.
– Guilherme Bernal
I reopened the question to be consistent with the way the community handled another code golf question. See the discussion on the goal linked by Guilherme Bernal.
– bfavaretto