a)output all odd numbers between num1 and num2 (including num1 and num2)
b)output the sum of all even numbers between num1 and num2
c)display information on two different lines
//Lab Assignment____
//Part 1 Using While Loop
#include <iostream>
using namespace std;
int main()
{
int num1,num2, //The users input
total,
even;
//Tell about the program and prompt user to input
//two integers.
cout << "This program will show you the odd numbers \n";
cout << "and sum of even numbers between two integers.\n";
cout << "Please enter two integers,the first one should \n";
cout << "be less than the second one.\n";
cin >> num1 >> num2;
while (num1 < num2)
{
num1++;
if (num1 % 2 != 0)
cout << " " << num1;
else
total = num1 + num1;
cout << total;
}
return 0;
}
*** MOD EDIT: Added code tags. Please
This post has been edited by JackOfAllTrades: 01 November 2009 - 02:33 PM

New Topic/Question
Reply




MultiQuote




|