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.
]#include<iostream>
usingnamespace 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;
}