+ 2
so this should print variable a up to the value x (wtever u enter) i dont know whats wrong it just prints a++ until it times out
int main() { int x; int a = 1; int b = 2; int c = 3; cin >> x; for(a < x;a++;){ cout << a << endl; } return 0;}
6 odpowiedzi
+ 9
for(; a < x; a++)
+ 5
this should be:
for(; a<x;a++)
ie
1) initialisation of counter ( absent in your case)
2)stop condition
3)increment
+ 1
#include <iostream>
using namespace std;
int main()
{ int x;
int a = 1; int b = 2; int c = 3;
cin >> x;
for(;a <= x;a++){
cout << a << endl;
}
return 0;
}
+ 1
the for loop must be changed !! it has
1-initialization 2-condition to stop 3-increment/decrement
0
I think you wanna the code to print the value of a (I.e 1) for x-times. if am right , modify
int main()
{ int x;
int a = 1; int b = 2; int c = 3,k=0;
cin >> x;
for(;k< x;k++;){
cout << a << endl;
}
return 0;}
and it will print 1 for x-times
0
declare int a,x;
and
try this loop
for(a=1;a<x;a++)