Discover a world of knowledge at Westonci.ca, where experts and enthusiasts come together to answer your questions. Join our platform to connect with experts ready to provide precise answers to your questions in different areas. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.
Sagot :
Answer:
Explanation:
//Include the required header files.
#include<iostream>
using namespace std;
//Define the main function.
int main()
{
//Define the variables.
int i, sum = 0, sqSum = 0, firstNum = 1, secondNum = 0;
char ch;
//Check for valid input.
while (!(firstNum < secondNum))
{
cout << "Enter starting number: ";
cin >> firstNum;
cout<<"Enter ending number(must be > startingNumber): ";
cin >> secondNum;
}
//Store first number in i
i = firstNum;
//Dispaly the number.
cout << "The odd numbers between " << firstNum
<< " and " << secondNum << " are:\n";
//Iterate between first and second number.
while (i <= secondNum)
{
//Check for even numbers.
//Store the sum
if (i % 2 == 0)
sum = sum + i;
//Print the odd numbers
//Evaluate the square of sum of odd number.
else
{
cout << i << " ";
sqSum = sqSum + i * i;
}
//Increase the value of i.
i++;
}
//Dispaly the sum of even numbers.
cout << "\n\nThe sum of the even numbers is:"
<< sum << endl << endl;
//Dispaly the sum of square of odd number.
cout << "The sum of squares the odd numbers is:"
<< sqSum << endl;
//Set i to 1.
i = 1;
//Dispaly the message.
cout << "\nNumber Square\n";
//Iterate and print number between 1 andd 10
//along with the sum.
while (i <= 10)
{
cout << " " << i << "\t " << i * i << endl;
i++;
}
//USe for visual studio.
system("pause");
//Return the value 0.
return 0;
}
Explanation:
The program code will perform the function listed below using loop.
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. Separate the numbers using any amount of spaces. Output the sum of the square of the odd numbers between firstNum and secondNum. Output all uppercase letters.
Hope this helps!
Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.