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
Diano4ka-milaya [45]
3 years ago
8

[This is on Edhesive (coding and programming)]

Computers and Technology
2 answers:
Ghella [55]3 years ago
6 0

Answer:

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

egoroff_w [7]3 years ago
6 0

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

Answer (Question 1):

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

Explanation (Question 1):

<u>Line 1 : </u>

Prompt user for input an integer.  In Python we can easily use <em>input </em>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 <em>int()</em> to convert the value from string to integer.

<u>Line 3 - 4:</u>

Create a for-loop to loop though the code in Line 4 for three times using the <em>range() </em>function. The <em>range(1, 4) </em>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 <em>print()</em> function.

Answer (Question 2):

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

Explanation (Question 2):

<u>Line 1 - 2 :</u>

Create a <em>counter</em> variable and a <em>sum</em> variable and initialize them with 3 and 0, respectively.

<u>Line 4:</u>

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

<u>Line 5:</u>

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

<u>Line 6:</u>

Every time when a decimal number is input, the number is added to the <em>sum</em> variable.

<u>Line 7:</u>

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.

<u>Line 9</u>

Display the sum.

You might be interested in
Compared with non-Internet users, today's online social networkers are likely to experience ________ relationships with their ex
Digiron [165]

Answer: Strengthened, less

Explanation:

With people spending more time on internet their relationships with existing friends have decreased due to lot of contents available on the internet. They might be friends with people miles away but they might not know their next door neighbor. As the content over the internet increases day by the day this trend shall keep on rising.

8 0
3 years ago
Ryan has made a presentation of ten slides, which he wants to display in sequence after a specific time interval. Which element
erastovalidia [21]
Open Slide how Tab Then Set up Group and then  Select Rehearse set each slide time according to your requirement
6 0
3 years ago
Read 2 more answers
A ______ oversees the planning and implementation of sophisticated security measures to block unauthorized access but at the sam
meriva
A-database administrator
8 0
3 years ago
What keyboard shortcut is used to move the cursor to the beginning or end of a document.
TiliK225 [7]
Ctrl+Home moves the cursor to the beginning of the document, and Ctrl+End moves the cursor to the end of a document. These shortcuts work with most documents, as well as web pages.
7 0
3 years ago
Want is the assignmment
AnnZ [28]
Can you explain this
4 0
3 years ago
Other questions:
  • - The __________ is called a single-selection statement.
    10·1 answer
  • What is a quick way to determine if a site might contain reliable information? looking at the title of the webpage reading the f
    5·2 answers
  • The conscious process of planning and controlling how you spend your time is called?
    15·1 answer
  • What do you do to add a line or circle to your presentation?
    7·2 answers
  • What is a router in computer networks?
    8·1 answer
  • Addison, Inc. uses a perpetual inventory system. Below is information about one inventory item for the month of September. Use t
    15·1 answer
  • Suppose that you have created a program with only the following variables.int age = 34;int weight = 180;double height = 5.9;Supp
    7·1 answer
  • Make a presentation on ms word
    6·2 answers
  • Choose a common cloud-based application from the lesson.(Infrastructure as a service, Software as a service, Platform as a servi
    5·1 answer
  • A combination of numbers and symbols used to express a calculation. Question 11 options: Formula Formula Bar Worksheet Workbook
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!