+ 1

What's wrong with this simple C++ code?

Why will this code give an error? #include <iostream> using namespace std; int main() { for (x=5;x<12;x++) { cout <<x; } } Is it because the variable x was not declared? Any other reasons?

22nd Jul 2020, 6:01 AM
Solus
Solus - avatar
4 odpowiedzi
+ 2
Yes, undefined variable <x> is the cause.
22nd Jul 2020, 6:05 AM
Ipang
+ 2
use it : for(int x = 5;x<12;x++)
22nd Jul 2020, 6:20 AM
Akash
Akash - avatar
+ 1
The datatype of x not defined any where.
23rd Jul 2020, 1:43 PM
shubham kumar
shubham kumar - avatar