Urgent: Help with a my assigment


I need a help with my lab assignment, I should submit it today, please if anyone can help me in this.


Write a C++ program that prompts the user to enter 20 integer numbers and then use an if-else statement to print the average of odd numbers. Please note you should use while loop counter to solve this problem.


Thank you,
- Abdulla
post your code
This is my first assignment and I am very starter in C++, please help me and provide me the code so I can see and check to learn.

Thank you,
Okay I'm on it, please wait.
Okay, I am waiting ... thank you.
WHILE you are waiting for someone else to do your homework for you I suggest you do your best to code it yourself. At least show an effort so we can guide you though the problem.

Just in case... since it's a policy around here NOT to provide full homework solutions... you may be waiting a loooong time... ;-).

BTW, don't fool yourself into thinking you can learn how to code by looking at someone else's work. You MUST write it yourself or you'll never REALLY know how to do it.
Last edited on
Aww come on, this is 10% coursework tops, maybe just 5%. Couldn't the lesson be taught the hard-way?
Last edited on
I am starting currently to learn C++ but I will need some time to do, it is not hard guys.
I should send this assignment today to my teacher, and the problem is I was absent in the past days on the class as I was have traffic accident.. the doctor give me this assignment and this is my first day on the class since one month!

Can you help me guys in this, as I am starting to learn the C++... Just I need to submit this assignment as he need it tonight... please.
It shouldn't take you more than an hour at the most to read these two pages and make an attempt at coding your program.


I doubt anyone here will help if you can't at least show you tried doing it yourself.
Hi sir,

Since morning I am trying to learn and I learn many things, but to be honest with you, I am very starter, I will need times to understand that... just help me guys in this.. thank you
@ Olysold: Hey don't get me wrong, I laughed. Then I laughed even harder when I saw abdulla's "I'm waiting..." response 8^D. But THEN... I felt bad and thought I would try to nudge him in the right direction since he's new here and all.

OK, abdulla. So you missed the past few days (or months?) and now you can't do the C++ assignment your doctor gave you??? Hmmmmm. 8^\

Look over the links posted above and try to get something coded. Here is some pseudo-code to guide you:

totalCount = 0
oddCount = 0
oddSum = 0

prompt user for number
IF number % 2 == 1 #If modulus(2) of number is 1 then it's odd
--- totalCount += 1
--- oddCount += 1
--- oddSum += number
--- totalCount += 1

IF totalCount = 20
--- break and output results to user # oddSum / oddCount equals odd average
Last edited on
Finally, I have done the code, please review it, can you check it please:

# include <iostream>

using namespace std;
intmain ( )
int x, i, count = 0;
double sum = 0;
cout << "Please enter 20 integers:\n";
for (i = 1; i <= 20; i++)
cin >> x;
if ( x % 2 != 0)
sum += x;
count ++;
if(count != 0)
cout << "Average of odd numbers: " << sum / count << endl;
cout << "No odd numbers!" << endl;
return 0;
Perfect. Just remember fix it so that there's a space here: intmain().
Be careful of integer division when you say sum / count towards the end of your program. I suggest sum / (double)count
Topic archived. No new replies allowed.