Ja-ja I'm new to this c++, BUT egger to learn. I want to write a program that will cout all the odd numbers between 6 and a positive integer.It must also be bigger than 53. This is what I came up so far but it doesn't give any output :

cout<<"Please enter a number not less than 53\n";
     int a, i;                         // Declare the number input
      cin>>i;
      while (i <= 53)
         { cout << "No, bigger than 53! Try again : ";
           cin >> i;
       for (a>6;a<=i;a++);              //Execution of the series
        if (a%2!=0);                    // calculating the odd numbers
         cout << a <<endl;
         cout <<"This is the odd numbers between 6 and "<<i<<"\n";
         cout<<endl;

Can anybody help? I'm sure there must be an easier way of doing this.
<email snipped>

Edited 3 Years Ago by pyTony: fixed formatting

> for (a>6;a<=i;a++); //Execution of the series
> if (a%2!=0); // calculating the odd numbers
The trailing ; on both these lines is a huge problem.

Next time, use [code]
[/code] tags around your code.

Comments
There is a [noparse] code tag :)

Here is the improoved version

#include<iostream.h>
void main(){
int n;
do
{
cout<<"\Enter a Value bigger than 53: ";
cin>>n;
}while(n>53);

for(int i=7,j=0;i<n;i+=2,j++);
cout<<"\nThere are ";
cout<<j;
cout<<" odd number between 6 and";
cout<<n;
}

void main is not an improvement, and nor is posting code without using CODE tags.

Edited 3 Years Ago by happygeek: fixed formatting

This article has been dead for over six months. Start a new discussion instead.