+ 2
Why no output?
9 ответов
+ 4
What output you expecting through this program
After for loop you wrote a=7 it working infinite times . but if u enter Big number which is more than 10 then its working one time
becoz condition false and a++ it will increase value by 1 . may be you want to print Numbers like 0,1,2,3.....9
#include <iostream>
using namespace std;
int main() {
int a;
for( a=0;a<10;a++)cout<<a<<endl;
return 0;
}
+ 2
https://code.sololearn.com/c53bHjySP7Kd/?ref=app
I solved your problem see in the code. Where you entered a<10 then entered a=7
Please put a= 10,11,or 12...........
+ 1
https://code.sololearn.com/c4JEqqrE0s6E/?ref=app
Or while replacing a<10 to a>10 then output will be 0 try it
Solved in 👆 in code
+ 1
#include <iostream>
using namespace std;
int main() {
int a;
for( a=0;a<10;a++){
a=7;
cout<<a<<endl;
}
return 0;
}
+ 1
What are you wanna do the code ?
Is it like this or something like that :)
for(int a =0;a<10;a++){
if (a == 7 )
cout << a<< endl;
}
0
7
0
Why it's infinite?
There is (a++)in the loop so,it would make it finite.
0
Replace trailing ';' at row 6 (the loop line) with ','
this way you will see output and what is happening
0
The variable a, every time the loop acts, it becomes 7 again as a value, so the loop is infinite, also, after the loop you should use curly braces for its function.
include <iostream>
using namespace std;
int main() {
int a;
for( a=0;a<7; a++) { }
cout<<a<<endl;
return 0;
}