0
#include <iostream using namespace std; int main(a= 2); { while(a <=100) cout<<"this is even"<< a << ln; }
what is wrong in that code
8 Respostas
+ 4
So start with a value of 0 in a.
int a = 0;
+ 3
A lot, it should be:
#include <iostream>
using namespace std;
int main()
{
int a = 2;
while(a <= 100)
{
cout << a << " is even" << endl;
a += 2;
}
return 0;
}
+ 2
Was it meant to be an infinite loop?
+ 2
I thought you wanted to print out all the evens from 2 to 100. a += 2 is the same as a = a + 2
So the value of a increases by two every loop.
+ 1
thanks
0
it is an infinite loop
0
what is the use of a+=2; statements
0
no I needed to find the evens btwn 0 to 100