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>

Recommended Answers

All 6 Replies

for ( int c = 7; c < i; c += 2)
    cout << c << "\n";

> 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.

commented: There is a [noparse] code tag :) +11

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.

Nice for loop

I believe the proper format is
for(int a = x ; a < y; a++)

Salem's request is to repost your code with formatting and Code Tags... When we can read the code, we can help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.