helo everyone...can you really write prog

i'm kind of new in C++. now is that,i'm in real need of any help to solve this question:

Write a program that uses loop to perform the following steps :
a. Prompt the user to input two integers: firstNum and secondNum (firstNum must be less than secondNum)
b. Output all odd numbers between firstNum and secondNum.
c. Output the sum of all even numbers between firstNum and secondNum.
d. Output the numbers and their squares between 1 and 10.
e. Output the sum of the square of the odd numbers between firstNum and secondNum.
f. Output all uppercase letters.

can neone,kindly write the entire prog..
my brain got crammed in the middle of the coding. Please,neone,help me!!
kindly write the entire prog

No.

my brain got crammed in the middle of the coding.

Then explain where you got stuck.
i got stuck at c.,d.
would you kindly xplain what should i do?
The task description already says what you should do.
If you managed to do b., then what's your problem with c.? Don't you know what a sum is (Google helps here) or don't you know yet about operators + and +=?
actually i merely escape at b. and e. .....emm,what does it seem like?emm..EntirE!haha..just kidding,but it really happen..the first statement.just please help me some more.thanx.
+=,how do u apply it?
i never had use it b4..
Well, I guess I can post a possible solution for b... that should help you with the rest.

1
2
3
4
5
//This assumes you already did a.
for (int i=firstNum;i<=secondNum;i++)
{
  if (i%2!=0)cout << i << endl;
}


+=,how do u apply it?

It's just a shorthand, e.g. a+=5; is short for a=a+5;
Last edited on
wow,you really did it dude..thanx a lot.
neway,i xpctd more if u willing..hehe
NEONE ELSE?????,lets kill this prob...cmon.
Why bother? You're going to fail this class. Hard.
Any of our (and your) time is wasted on this.
well,i wasted it for good,obviously...
why dont u put 'neither of' b4 the word 'Any'...sounds better.
Last edited on
I think you should be the last one to tell anyone else how to spell.
That typing style of yours may be faster to type for yourself, but it makes it very hard for others to read. It's not that hard to spend 10 more seconds.
Athar, I strongly object to your last statement to the point that you'd get hit over the head, hard, with a dead albatross (not chicken) if I were nearby.

That said, I will (like most members here) not do your work for you. I will however "waste some of my time" and give you two links that might help you out somewhat, depending on how you use them.

http://cplusplus.com/reference/clibrary/cmath/ (useful for d and e)
http://cplusplus.com/doc/tutorial/ <- This should also help if you read it.

http://cplusplus.com/forum/beginner/1/ <- ...And please read this before posting anything else here.

-Albatross
@Albatross

He has made it quite obvious that he has zero interest in doing any work himself.
At the beginning he might somehow manage to get through the course by scraping tidbits of code together that he manages to squeeze out of people, but obviously that will no longer work once the assignments get more complex.
Maybe. The OP is reluctant to do any of the major work.
can neone,kindly write the entire prog.


After Athar explained that one could use +=.
just please help me some more.thanx.


After Athar posted the solution:
wow,you really did it dude..thanx a lot.
neway,i xpctd more if u willing..hehe


Still, it might not be time wasted. Therefore, I'll just clock you with a seagull. ;)

-Albatross
Last edited on
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
int firstNum, secondNum;
int sumEvenNum = 0;
int sumSquareOddNum = 0;

char chCounter;

int counter;

cout << "name" << endl;

//Part a
cout << "Enter two numbers." << endl;
cout << "First number must be less than ";
cout << "the second number you enter" << endl;
cout << "Enter numbers: " << flush;
cin >> firstNum >> secondNum;
cout << endl;

//Part b
if (firstNum % 2 == 0)
counter = firstNum + 1;
else
counter = firstNum;

cout << "Odd integers between " << firstNum << " and "
<< secondNum << " are: " << endl;

while (counter <= secondNum)
{
cout << counter << " ";
counter = counter + 2;
}

cout << endl;

//Part c
if (firstNum % 2 == 0)
counter = firstNum;
else
counter = firstNum + 1;

while (counter <= secondNum)
{
sumEvenNum = sumEvenNum + counter;
counter = counter + 2;
}

cout << "Sum of even integers between " << firstNum << " and "
<< secondNum << " = " << sumEvenNum << endl;

//Part d
cout << "Number Square of Number" << endl;
counter = 1;
while (counter <= 10)
{
cout << setw(4) << counter << setw(18)
<< counter * counter << endl;
counter++;
}

cout << endl;

//Part e
if (firstNum % 2 == 0)
counter = firstNum + 1;
else
counter = firstNum;

while (counter <= secondNum)
{
sumSquareOddNum = sumSquareOddNum + counter * counter;
counter = counter + 2;
}

cout << "Sum of the squares of odd integers between "
<< firstNum << " and " << secondNum << " = "
<< sumSquareOddNum << endl;

//Part f
cout << "Upper case letters are: ";

chCounter = 'A';
while (chCounter <= 'Z')
{
cout << chCounter << " ";
chCounter++;
}
cout << endl;


cin.ignore(cin.rdbuf()->in_avail() + 1);

cout << "Press the enter key to exit";
cin.ignore(cin.rdbuf()->in_avail() + 1);

return 0;
}
//just finish it...thanx a lot Athar.you can copy my work for free.
Topic archived. No new replies allowed.