c++ - Why this easy program isn't working? -
#include <iostream> #include <conio.h> int main() { int i; (i = 1; = 100; 1 + 1); { std::cout << << " = " << *i << std::endl; } { std::cout << << " = " << *i << std::endl; } while (i = 100) getch(); }
why isn't working @ all. sapoust give cube numbers of numer 1 100 , opens , nothing happens. can ?! i'm beginner , cant solve problem. thanks
you have number of mistakes, e.g.
for ( = 1 ; = 100 ; 1+1 ) ;
should be:
for ( = 1 ; <= 100 ; += 1 )
(note removal of stray ;
other changes).
also:
while ( = 100 )
should be:
while ( <= 100 );
(note addition of missing ;
change =
<=
).
you want re-initialise i
prior do
loop, , increment within loop:
i = 1; { std::cout << << " = " << * << std::endl; += 1; } while (i <= 100);
Comments
Post a Comment