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
The process of a web server adding a tcp header to a web page, followed by adding an ip header, and then a data link header and
kumpel [21]
<span>Encapsulation is defined as the process of adding a header in front of data supplied by a higher layer (and possibly adding a trailer as well).</span>
7 0
3 years ago
Is apple better than android
KatRina [158]

In a sense yes as it has a more user friendly interface but in terms of usability android is a far better os

3 0
3 years ago
Read 2 more answers
Where is the Name Manager dialog box found?
Sonbull [250]
 The Name Manager<span> dialog box is found, on the </span>Formulas<span> tab, in the </span>Defined Names<span> group, click </span>Name Manager<span>.</span>
6 0
3 years ago
The secure evidence locker is located at the ____.
olga55 [171]
The data recovery lab

Data recovery can be done in special rooms called data recovery labs. Data that has been salvaged, lost, or inaccessible from removable media or secondary storage can be accessed in a normal way. Recovery of this kind may be required due to the physical damage caused.

 

 

 





5 0
3 years ago
"while executing programs from the command line, most operating systems also allow the user to specify one or more ____________
Rudik [331]
The answer could possibly be "parameters"
6 0
3 years ago
Other questions:
  • Instructions:Select the correct answer.
    13·1 answer
  • A __engineer specializes in computer hardware design and integration.
    15·1 answer
  • Rubbing two sticks together to make a fire is an example what
    11·2 answers
  • The rule of thumb that predicts that the number of transistors on a cpu will double every two years is called ________ law.
    7·1 answer
  • Kiara is using her software's graphic formats to create a line graph. As she
    9·2 answers
  • How to solve a program that accepts a number as input and prints just the decimal portion
    15·2 answers
  • Question 1. (50 points) 1.Write a program that computes information related to a sequence of entries regarding age of customers.
    6·1 answer
  • During his last performance review, Franco's boss urged him to set some short-term and long-term sales goals to help him perform
    6·2 answers
  • If I want to add a new slide to my presentation, which option would I click on?
    5·1 answer
  • What is the key difference between UDP and TCP protocols in TCP/IP reference model?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!