All pastes #732548 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-10-11 02:25 UTC
rendered paste body
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int lowNum, highNum, fixer;
    cout << "Enter two integer values.\n";
    cin >> lowNum >> highNum;
    fixer = highNum;
    if (highNum<=lowNum) //this if statement makes it so the numbers can be entered in whatever order
    {
     highNum = lowNum;
     lowNum = fixer;
    }
    int count = lowNum + 1;
    int top = highNum - 1;
    cout << "Display of all odd numbers between " << lowNum << " and " << highNum << ". ";
    while (count <= top)
    {
          if (count % 2 != 0)
          cout << count << " ";
          count ++;
    }
    cout << "\n";
    count = lowNum + 1;
    int sum = 0;
    while (count <= top)
    {
          if (count % 2 == 0)
           sum = sum + count;
           count++;      
    }
    cout << "Sum of all even numbers between " << lowNum << " and " << highNum << "= " << sum;
    cin.get();
    cin.get();
}