I need a while loop to do the following:
A:Get the user to input 2 integer values;
B:Output all of the odd #'s between the odds;
C:Output the sum of all the even #'s between them;
D:output #'s and their squares between 1 and 10;
E:Output the sum of the squares of the odd numbers between them.
F: Output all uppercase letters.
I think I have A working correctly but I am hung up on B. Any help is greatly appreciated!
Here is what I have so far.
CODE
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int firstNum;
int secondNum;
int n;
int sum;
cout << "Please enter two numbers." << endl;
cout << "(First Number must be less than second number.)" << endl;
cin >> firstNum >> secondNum;
for(n=firstNum;n<=secondNum;n++)
{
if(n%2==0)
{
//even number
}
else
// odd number
{
cout << "The odd numbers are: " << n << endl;
}
}
for(int n=firstNum;n<=secondNum;n++)
if(n%2==0)
sum += n;
else
//odd
{
cout<< "The sum of all even numbers between two numbers: " << sum << endl;
}
system ("PAUSE");
return 0;
}
This post has been edited by monkjessica: 18 Jul, 2007 - 02:59 PM