For
As i learned from tutorial,
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
using namespace std;
int main()
{
int broj;
for (broj = '1'; broj++ <= '100';)
cout << broj << "\n";
return 0;
}
|
Should count to 100 and stop. But it never stop! Why?
This shouldn't even compile
first, you assign letter '1' to broj, not a number (notice the single quotes).
Second,
broj++ <= '100'
is wrong. It must be
broj<100; broj++;
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
using namespace std;
int main()
{
int broj;
for (broj = 1; broj<=100;broj++)
cout << broj << "\n";
return 0;
}
|
Last edited on
Topic archived. No new replies allowed.