| | |
Odd numbers in C++?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2007
Posts: 2
Reputation:
Solved Threads: 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>
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>
Last edited by Ancient Dragon; Oct 21st, 2007 at 5:49 pm. Reason: email snipped
c++ Syntax (Toggle Plain Text)
for ( int c = 7; c < i; c += 2) cout << c << "\n";
"Hey ass, don't hijack my thread. This is serious." -JoshSCH
Salem's request is to repost your code with formatting and Code Tags... When we can read the code, we can help.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- Loop counting odd and even numbers (C++)
- add even (or odd) numbers from input (C++)
- Adding the sum of odd numbers. Please help (Visual Basic 4 / 5 / 6)
- (Noob) need some help w/ Prime Numbers (C++)
- print odd and even numbers (Assembly)
- Odd And Even (Java)
Other Threads in the C++ Forum
- Previous Thread: Connect a SQL database to a C++ application
- Next Thread: I'm looking for a good C++ programer (need help with COMports)
Views: 2070 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






