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

3 answers

Find the value of x.

Find the value of x. [tex]Find the value of x.[/tex]...
5 answers

Which image demonstrates poor accuracy but good percision

Which image demonstrates poor accuracy but good percision...
4 answers

Which of the following are the steps to a 'Healthy Lifestyle Planning,' select all thatapplyCollaborate with a classmate to keep you motivatedFind

Which of the following are the steps to a "Healthy Lifestyle Planning," select all that apply Collaborate with a classmate to keep you motivated Find a personal trainer Ask a friend for advice and never write anything down O Workout 6 days a week Structure your program and write it down Keep a log...
3 answers

About 80 percent of earth’s volume is made up of a. crust. c. inner core. b. mantle. d. outer core.

About 80 percent of earth’s volume is made up of a. crust. c. inner core. b. mantle. d. outer core....
4 answers

During the Gilded Age, we see America rise as a world power. How do you think this relates to the role

During the Gilded Age, we see America rise as a world power. How do you think this relates to the role of the United States in the world today? Is the nation the same/similar to that time? Have we changed and if so, how?...
2 answers

What was the significance of the 1968 jones v. mayer supreme court ruling?

What was the significance of the 1968 jones v. mayer supreme court ruling?...
4 answers

Which represents the correct electron configuration of a group 18 element?

Which represents the correct electron configuration of a group 18 element?...
10 answers

How many representatives does the city of new york have?

How many representatives does the city of new york have?...
3 answers

What scale is delivery performance a nominal or ordinal scale?​

What scale is delivery performance a nominal or ordinal scale?​...
4 answers

The following types of glial cells (supportive cells) are responsible for helping to synthesize myelin, the insulation of axons:

The following types of glial cells (supportive cells) are responsible for helping to synthesize myelin, the insulation of axons: in the central nervous system (CNS) and in the peripheral nervous system (PNS.)...
5 answers

Which of the following could be the rectangle length and width?

Which of the following could be the rectangle length and width? [tex]Which of the following could be the rectangle length and width?[/tex]...
2 answers

Iwill give brainliest and 10 points ! solve the equation using inverse operations. check your solutions.

Iwill give brainliest and 10 points ! solve the equation using inverse operations. check your solutions. in your final answer, include all of your work. 5 - 2 x y^2 = -15 solve for y...
9 answers

Fr point bug Alex

Fr point bug Alex...
3 answers

Why is the image of the setting sun most likely not described in great detail in 'Because I Could Not Stop for Death'?It is

Why is the image of the setting sun most likely not described in great detail in "Because I Could Not Stop for Death"? It is a common symbol of death that requires little description. It is a part of the plot that does little to contribute to the theme. It is not meant to be seen as an important sy...
4 answers

The ratio of the radii of two distinct spheres is 1: 2. what is the ratio of their respective volumes?

The ratio of the radii of two distinct spheres is 1: 2. what is the ratio of their respective volumes? a. 1: 2 b. 1: 6 c. 1: 8 d. 1: 4...
7 answers

1 + 1 + 2 + 9 =

1 + 1 + 2 + 9 =...
4 answers

15 × (-4) ÷ 5 please

15 × (-4) ÷ 5 please...
4 answers

How abt meeting now?someone give the code pls

How abt meeting now? someone give the code pls...
10 answers

Need help ASAP. Will give you brainlist.

Need help ASAP. Will give you brainlist. [tex]Need help ASAP.Will give you brainlist.[/tex]...
6 answers

(ITS SO EZ ITS A MULTIPLE CHOICE AND IM IN 5 GRADE HELP ME BIG PEOPLE)

(ITS SO EZ ITS A MULTIPLE CHOICE AND IM IN 5 GRADE HELP ME BIG PEOPLE) [tex](ITS SO EZ ITS A MULTIPLE CHOICE AND IM IN 5 GRADE HELP ME BIG PEOPLE)[/tex][tex](ITS SO EZ ITS A MULTIPLE CHOICE AND IM IN 5 GRADE HELP ME BIG PEOPLE)[/tex]...

-- 0.053639--