#include <iostream>
using namespace std;
int main()
{
int firstNum, secondNum;
cout << "1. Input firstNum and secondNum:\n";
cin >> firstNum >> secondNum;
int sumOfEven=0, sumOfSqOdd=0;
cout << "2. All odd numbers between " << firstNum << " and " << secondNum << ":\n";
for (int i=firstNum; i<=secondNum; i++)
{
if (i%2==1)
{
cout << i << " ";
sumOfSqOdd += i*i;
}
else
{
sumOfEven += i;
}
}
cout << "\n3. Sum of evens:\n" << sumOfEven <<endl;
cout << "4. Numbers between 1 and 10 and and their squares:\n";
for (int i=1; i<=10; i++)
{
cout << i << " " << i*i << endl;
}
cout << "5. Sum of the square of the odd numbers:\n";
cout << sumOfSqOdd << endl;
cout << "6. All uppercase letters:\n";
for (char i='A'; i<='Z'; i++)
{
cout << i << " ";
}
}
Comments
Dear visitor, please use panel for submitting new questions
Write a program that uses do while loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNum (firstNum must be less than secondNum). Output all odd numbers between firstNum and secondNum. Output the sum of all even numbers between firstNum and secondNum. Output the numbers and their squares between 1 and 10 . Output the sum of the square of the odd numbers between firstNum and secondNum. Output all uppercase letters
Leave a comment