0

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 by pyTony: fixed formatting

6
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by WaltP
Featured Replies
  • 1
    Salem 5,138   9 Years Ago

    > 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 [cod[b][/b]e][/code] tags around your code. Read More

1

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

Votes + Comments
There is a [noparse] code tag :)
0

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;
}

0

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

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.