InstructionsAsk the user to input an integer. Print out the next three consecutive numbers.Sample RunEnter an integer: 4567

7 answers
Question:

Instructions Ask the user to input an integer. Print out the next three consecutive numbers.
Sample Run
Enter an integer: 4
5
6
7

Answers

a = float(input("Enter an integer: "))

print(a + 1)

print (a + 2)

print (a + 3)

Explanation:

Takes any number user inputs, and next three numbers that come out are what the given number is plus one, then two, then three.

For example :

Enter an integer: 4

5

6

7

Codes are given below:

Explanation:

Since the language is not specified, I am writing it in c++

#include <iostream>

 using namespace std;

 int main()    //Start of main function

{

 int number;  

  cout << "Enter your number"<<endl;

  cin >> number;     //this will take your number as an input

  cout <<"The next three numbers are: " << number + 1 << endl; //this will write the next number to your input input

  cout << number + 2 << endl;

  cout << number + 3 << endl;  

   return 0;

}   //End of main function

Codes are given below:

Explanation:

Since the language is not specified, I am writing it in c++

1) Ask the user to input an integer. Print out the next three consecutive numbers.

#include <iostream>

 using namespace std;

 int main()    //Start of main function

{

  int number;  

   cout << "Enter your number<<endl;

  cin >> number;     //this will take your number as an input

 

  cout <<"The next three numbers are: " << number + 1 << endl;

  cout << number + 2 << endl;

   cout << number + 3 << endl;  

  return 0;

}   //End of main function

2) Write a program that accepts three decimal numbers as input and outputs their sum.

#include <iostream>

 using namespace std;

 int main()    //Start of main function

{

  int number1, number2, number3;  

   cout << "Enter your three numbers<<endl;

  cin >> number1 >> number2>> number3 ;     //this will take your three number as an input

 

  cout <<"The sum of three numbers are: " << number1 + number2+ number3 <<  endl;  

  return 0;

}   //End of main function

Explanation:

n = int(input("Enter Number : "))

print(n+1,n+2,n+3)

I've included my code in the picture below. Best of luck.


[tex]Ask the user to input an integer. Print out the next three consecutive numbers. Sample Run Enter an[/tex]

num = int(input("Enter an integer: "))

i = 1

while i <= 3:

   print(num+i)

   i += 1

I've written my code in python 3+. I hope this helps!

The code is written using Python language as it is one of the programming languages introduced by the Edhesive courses.

Answer (Question 1):

num = int(input("Input an integer: "))for i in range(1, 4):    print(num + i)

Explanation (Question 1):

Line 1 :

Prompt user for input an integer.  In Python we can easily use input method to ask user for an input.

However the default data type of the input is a string and therefore we need to enclose our input value within int() to convert the value from string to integer.

Line 3 - 4:

Create a for-loop to loop though the code in Line 4 for three times using the range() function. The range(1, 4) will return a list of numbers, [1, 2, 3] .

In each round of the loops, one number from the list will be taken sequentially and total up with the input number, num and display using print() function.

Answer (Question 2):

counter = 3sum = 0while (counter > 0):    num = float(input("Enter a decimal number: "))    sum += num    counter = counter - 1print("The sum is " + str(sum))

Explanation (Question 2):

Line 1 - 2 :

Create a counter variable and a sum variable and initialize them with 3 and 0, respectively.

Line 4:

Create a while loop and set a condition while counter is bigger than zero, the loop should keep running the code from Line 5-7.

Line 5:

Use input function again to prompt user for a decimal number. This time we need to use float function to convert the input value from string to decimal data type.

Line 6:

Every time when a decimal number is input, the number is added to the sum variable.

Line 7:

Decrement the counter variable by 1. This step is important to ensure the while loop will only be repeated for three times and each loop will only accept one input value from user.

Line 9

Display the sum.

Similar Solved Works

4 answers

Kayla wanted to open her own dress design business. She spent a few hours putting together a marketing plan, then selected an

Kayla wanted to open her own dress design business. She spent a few hours putting together a marketing plan, then selected an award-winning dress she designed and wore it to the meeting with the bank. The most likely reason she did not receive a loan was:...
8 answers

Imagine not having a rare username

Imagine not having a rare username [tex]Imagine not having a rare username[/tex]...
3 answers

Which of the following items is the most likely to have a mass of 3 mg? a : cat b : pumpkin c : ant

Which of the following items is the most likely to have a mass of 3 mg? a : cat b : pumpkin c : ant d : piano...
10 answers

Is the following conditional true or false? if it is true, explain why. if it is false, give a counterexample.

Is the following conditional true or false? if it is true, explain why. if it is false, give a counterexample. if it is snowing in dallas, texas, then it is snowing in the united states....
3 answers

Antyany saved $6.00 less than 3times as much money as his younger sister diana. if deanna d rollers anthony saved doller

Antyany saved $6.00 less than 3times as much money as his younger sister diana. if deanna d rollers anthony saved doller [tex]Antyany saved $6.00 less than 3times as much money as his younger sister diana. if deanna d rollers[/tex]...
4 answers

Help pls and ty ;-;..btw u should alow us to copy n paste questions.

Help pls and ty ;-;.. btw u should alow us to copy n paste questions. [tex]Help pls and ty ;-;.. btw u should alow us to copy n paste questions.[/tex]...
4 answers

A map has a scale of 1 inch =35 miles what is the distance if the distance on the map is 3.5

A map has a scale of 1 inch =35 miles what is the distance if the distance on the map is 3.5...
3 answers

Let me know some , I’m high my bad

Let me know some , I’m high my bad [tex]Let me know some , I’m high my bad[/tex]...
3 answers

Azebra cell is just about to replicate its dna. which of the following will happen first? a. all of the cells dna attach

Azebra cell is just about to replicate its dna. which of the following will happen first? a. all of the cells dna attach to protein b. dna folds over on itself to create a dense chromosome c. the dna unravels to make two strands d. rna attaches to dna...
7 answers

On a scale 1-10 how pretty am I (I'm the one with brown hair) 1-being ugly 10-being pretty

On a scale 1-10 how pretty am I (I'm the one with brown hair) 1-being ugly 10-being pretty [tex]On a scale 1-10 how pretty am I (I'm the one with brown hair) 1-being ugly 10-being pretty[/tex]...
4 answers

Which is the best system to measure the likelihood of an event occuringbetween 0 and 1/2between 0 and 1between 0 and 10between 0 and 100i will mark

Which is the best system to measure the likelihood of an event occuring between 0 and 1/2 between 0 and 1 between 0 and 10 between 0 and 100 i will mark brainliest...
4 answers

The waste material that comes from discarded computer technology items peripherals and electronic information devices such

The waste material that comes from discarded computer technology items peripherals and electronic information devices such as computers printers software devices and monitors is known as a. pre-consumer waste b. post-consumer waste c. e-waste d. rucksack...
3 answers

Deus vult deus vult deus vult

Deus vult deus vult deus vult...
3 answers

Solve the formula for the indicate variable a=zv+x, for v

Solve the formula for the indicate variable a=zv+x, for v...
10 answers

Need help, was doing this in environmental science

Need help, was doing this in environmental science [tex]Need help, was doing this in environmental science[/tex]...
10 answers

What is the equation of the line with an x intercept of -1 and a y intercept of 2

What is the equation of the line with an x intercept of -1 and a y intercept of 2...
4 answers

How and why would you use emotions in a speech? (site 1 )

How and why would you use emotions in a speech? (site 1 )...
3 answers

What political ideology triumphed at the conclusion of the decembrist uprising

What political ideology triumphed at the conclusion of the decembrist uprising...
3 answers

John, a limited partner of Candy Apple, LP, is allocated $25,000 of ordinary business loss from the partnership. Before the loss allocation,

John, a limited partner of Candy Apple, LP, is allocated $25,000 of ordinary business loss from the partnership. Before the loss allocation, his tax basis is $18,000 and his at-risk amount is $8,000. John also has ordinary business income of $18,000 from Sweet Pea, LP, as a general partner and ordin...
4 answers

Pakop tests his new car by accelerating uniformly from rest and reaches aspeed of 22.0 m/s in 9.00 s. If the diameter of a

Pakop tests his new car by accelerating uniformly from rest and reaches a speed of 22.0 m/s in 9.00 s. If the diameter of a tire is 58.0 cm, find:a. the number of revolutions the tire makes during this motion, assumirthat no slipping occurs. b. what is the final angular speed of a tire in a revolut...

-- 0.011710--