WAP in C++ to show first 10 odd numbers

Q.WAP in C++ to show first 10 odd numbers.
Ans
#include<iostream>
using namespace std;
int main()
{
int i=1;a=1;
for(i=0;i=10;++)
{
a+=2;
}
cout<<a<<".";
return 0;
}


plz explain dry run of for statement and also tell how the output starts with 1.Thanx.
The for() loop is incorrect.
try this
1
2
3
4
5
6
7
8
9
10
11
12
13
]#include<iostream>
using namespace std;
int main()
{
int i=1;a=1;
for(i=0;i<=10;i++) // in for(initialization ; condtion ; incre/decre)   do like this 
                                
{
a+=2;
}
cout<<a<<".";
return 0;
}
Topic archived. No new replies allowed.