1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dsp73
3 years ago
15

Write a program that uses for loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNu

m (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.

Computers and Technology
1 answer:
Artist 52 [7]3 years ago
6 0

Answer:

//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.

Check the attachment for its output and program screenshot.

You might be interested in
How many unique combinations from 12 bit?
svet-max [94.6K]
This is calculated by raising 2 to the power of the number of bits.

2^12 = 4096
3 0
3 years ago
Clay wants to print T-shirts and sell them online. What printing press would be the best for him to use?
valkas [14]

Answer:

I think is screen printing press.

Explanation:

Screen printing requires you to go through a multi-step, back-breaking process to print your t-shirt.

3 0
3 years ago
Please help asap
NNADVOKAT [17]

Answer:

a. Comparison of if-else and elif:

if else follow as:

If (Condition)

{

In case if condition true, expression in this section executes

}

else

{

In case condition is false, expression in this section executes

}

elif Statement follows as:

If (Condition)

{

In case if condition true, expression in this section executes

}

{

in case, condition is false, move to elif block

elif (Condition)

{

In case elif condition true, expression in this section executes

}

else

{

In case elif condition is false, expression in this section executes

}

}

Explanation:

In if else, program first check the condition in "if statement", if condition is true it move into the body of "if " and execute the expression. If the condition is false it moves to the body of "else" and execute the expression.

elif is another block of condition in If else condition,It works as in "if statement" if the condition is true the program executes the expression of body of "if body". If the condition is false, it moves to another block of "elif", where it again check some other condition found in "elif statement". If the condition of "elif statement" is true it executes the expression of "elif body" otherwise in case of false condition it execute the expression in "else body".

It follows as: if - elif-else

Answer

b. the relational operators

Relation operators are the operators that are need in the expression to establish relationship between different operands of the expression.

Explanation:

In few expressions, their are some operators used to establish or show the relationship between different operands. These operator could be Equal (=), Greater than(>), Less than (<), Greater than equal to (>=) and Less than Equal to (<=).

These operators can be used in conditional statements that are used to check the relationship between operands and values through these operators.

Example

if (a>5)

{

if value of is greater than 5 then body of if will execute.

}

else

{

If value of a is less or equal to 5, this section will execute.

}

5 0
3 years ago
2. Does the government have the right to tell you what religion you should follow? Why or why not?
lapo4ka [179]

No they shouldn’t Because we all have the rights to pick our selves

4 0
3 years ago
Read 2 more answers
Output values below an amount
elena-s [515]

Answer:

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

  for value in user_values:

      if value < upper_threshold:

          print(value)  

def get_user_values():

  n = int(input())

  lst = []

  for i in range(n):

      lst.append(int(input()))

  return lst  

if __name__ == '__main__':

  userValues = get_user_values()

  upperThreshold = int(input())

  output_ints_less_than_or_equal_to_threshold(userValues, upperThreshold)

Explanation:

5 0
3 years ago
Other questions:
  • What is a URN (include example)
    13·1 answer
  • Hydropower uses moving water to do work, such as grinding grains in a mill. True False
    7·1 answer
  • The protocol that enables computers on the Internet to communicate with one another is called _____.
    10·2 answers
  • When you first start your computer, which software will have to start first?
    5·2 answers
  • Which describes a composite primary key? Check all that apply.
    11·1 answer
  • How do you run a function in python?
    5·1 answer
  • According to the SANS Institute, a __________ is typically a document that outlines specific requirements or rules that must be
    13·1 answer
  • On mad max ps4, why does the v6 sound beter and healthier than the v8
    8·1 answer
  • How bout these chose your fave for bnha
    14·2 answers
  • Which device is used to direct the flow of data on a computer network?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!