Solution to Write a program that uses do...while loops to perform the following steps: Prompt the user … - Sikademy
Author Image

Archangel Macsika

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. Separate the numbers by any amount of spaces. Output the sum of the square of the odd numbers between firstNum and secondNum. Output all uppercase letters.

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question

using namespace std;


/*
	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.
	Separate the numbers by any amount of spaces.
	Output the sum of the square of the odd numbers between firstNum and secondNum.
	Output all uppercase letters.
*/


int main()
{
	int firstNum=0,secondNum=0,n,Sum=0;
	
//	Prompt the user to input two integers: firstNum and secondNum
//	(firstNum must be less than secondNum).
	while(secondNum<=firstNum)
	{
		cout<<"\n\tEnter first  Number: "; cin>>firstNum;
		cout<<"\n\tEnter second Number: "; cin>>secondNum;
		cout<<"\n\tSecond Number should be greater than first Number.";
	}


//	Output all odd numbers between firstNum and secondNum.
	cout<<"\n\tOdd Numbers; ";
	Sum = 0;
	for(n=firstNum;n<=secondNum;n++)
	{
		if(n%2==1) cout<<n<<", ";
	}


//	Output the sum of all even numbers between firstNum and secondNum.
	cout<<"\n\n\tEven Numbers; ";
	for(n=firstNum;n<=secondNum;n++)
	{
		if(n%2==0) cout<<n<<", ";
	}


	cout<<"\n\n\tOutput the numbers and their squares between 1 and 10.";
//	Separate the numbers by any amount of spaces.
	for(n=firstNum;n<=secondNum;n++)
	{
		if(n<10) cout<<"\n\tNumber = "<<n<<"\tSquare("<<n<<") = "<<n*n;
	}
	


	cout<<"\n\n\tOutput the sum of the square of the odd numbers between firstNum and secondNum.";
	Sum = 0;
	for(n=firstNum;n<=secondNum;n++)
	{
		if(n%2==1) Sum = Sum + n*n;
	}
	cout<<"\n\tSum = "<<Sum;
	
	cout<<"\n\tOutput all uppercase letters.\n";
	for(n=0;n<26;n++) cout<<char('A'+n)<<" ";
	return(0);

}



Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1079-qpid-75