answer.
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
earnstyle [38]
2 years ago
5

Write a while loop that prints user_num divided by 2 until user_num is less than 1. The value of user_num changes inside of the

loop. Sample output with input: 20 10.0 5.0 2.5 1.25 0.625
Computers and Technology
1 answer:
WITCHER [35]2 years ago
8 0

Answer:

The code to this question can be defined as follows:

Code:

#include <stdio.h> //defining header file

int main() //defining main method

{

float user_num; //defining float variable

printf("Enter a value: "); //message

scanf("%f",&user_num); //input value from user end

printf("%f, ",user_num); //print value

while (user_num>1) //loop to calculte value

{

user_num=user_num/2; //diving value

printf("%f, ",user_num); //print value.

}

   return 0;

}

Output:

Enter a value: 20

20.000000, 10.000000, 5.000000, 2.500000, 1.250000, 0.625000,  

Explanation:

Description of the code as follows:

  • First, a float variable "user_num" is declared, in which we take input from the user-end.
  • In the next step, a while loop is declared, that uses the above variable to calculates its value.
  • Inside the loop variable "user_num" divide its value by 2 and holds its calculated value, to print its value the "printf" method is used that prints its value.  
You might be interested in
Write a function named "list_concat" that takes a list of strings as a parameter and returns the concatenation of all the values
Marina CMI [18]

Answer:

Following are the program in python language:

def list_concat(ls): #define function

if(len(ls) == 0): #set if condition

return ""

res = ""

for x in ls: #set for loop

res += x + " "

return res[:len(res)-1] #removing the extra spaces from list

ls = ['limit','break','ready'] #initialize the value in list

print(list_concat(ls)) #call the function

Output:

limit break ready

Explanation:

Here we declared a function "list_concat()" in which we pass an argument "ls" then check if condition that check the length of list .We also Iterating  the loop in that function  res[:len(res)-1] statement removes the extra space from the list and finally print the list

7 0
1 year ago
The word “computer” has become associated with anything related to screens and keyboard. However, these are not the only parts t
Digiron [165]

Explanation: The CPU is the main control chip which calculates what has to be done in order for your computer to function.

(Very interesting question you had. Hope this answer helps)

4 0
1 year ago
You have been employed as a technical consultant to a computer shop chain. You are given the task of creating a short consumer b
brilliants [131]

Answer:

The five factors to consider when trying to choose between a Solid State Drive, a Hard Disk Drive and, an External Hard Disk Drive are:

  1. Read/Write Speed
  2. Weight
  3. Power Consumption
  4. Cost
  5. Storage Capacity

  • Solid State Drives (SSDs) are typically lighter in weight, faster and do not consume much power.
  • Hard Disk Drives are relatively cheaper than SSDs. They also come with higher storage capacities but are more power-hungry and slower because they rely on mechanical/moving parts to read and write data.
  • External HDDs are the cheapest of the three. They are not internal which is a major drawback given the additional weight. However, they come with gargantuan storage capacities that make you want to rethink having one. Besides, unlike SSDs, you can easily get them in computer accessories shops offline or online.

Cheers!

3 0
2 years ago
What is retrieved from a search containing two terms separated<br> by the AND operator?
egoroff_w [7]

Answer:

A AND B= 1 or 0

1 1  1

0 1  0

1 0  0

0 0 0

So, as explained above if both are 1 we then only get 1, or else we get 0 always in case of AND which is a logical operator, whose output can be 0 or 1 only. This is being depicted above.

Explanation:

If both are 1 we get 1 or always else, we get the output =0.

8 0
2 years ago
Write a statement to add the key Tesla with value USA to car_makers. Modify the car maker of Fiat to Italy. Sample output for th
marishachu [46]

Answer:

Input code:

car_makers = {'Honda': 'Japan', 'Fiat': 'Germany'}

#add Tesla and USA as corresponding value

car_makers['Tesla'] = 'USA'

#change Fiat entry to Italy instead of Germany

car_makers['Fiat'] = 'Italy'

print(car_makers)

print('Honda made in', car_makers['Honda'])

print('Fiat made in', car_makers['Fiat'])

print('Tesla made in', car_makers['Tesla'])

Explanation:

The first line is a define object in the python code, containing two entries of Honda and Fiat and their respective countries.

The python code adds an entry to the object "car maker" using the bracket notation, the tesla car from USA.

The country of the Fiat car is changed from Germany to Italy, using the bracket notation.

The output of the complete object and the individual cars is given.

<u>output of the python code:</u>

{'Honda': 'Japan', 'Fiat': 'Italy', 'Tesla': 'USA'}

Honda made in Japan

Fiat made in Italy

Tesla made in USA.

7 0
2 years ago
Other questions:
  • Julie bought a house for $315,000 and has a $285,000 mortgage. she claims she has $315,000 in equity. is she correct? if not, ho
    12·2 answers
  • Which of the following best describes the concept behind Web 2.0
    5·1 answer
  • A slide contains three text boxes and three images that correspond to the text boxes. Which option can you use to display a text
    5·2 answers
  • A good website design combines which of the following elements? (select all that apply) powerful web server hardware components
    9·2 answers
  • You are attempting to open a file containing a list of integer numbers, each on a separate line, and read them into Python as in
    6·1 answer
  • Why is the following statement true - ideally, your information is abbreviated
    10·2 answers
  • The Pentium 4 Prescott processor, released in 2004, had a clock rate of 3.6 GHz and voltage of 1.25 V. Assume that, on average,
    8·1 answer
  • 10. (P37) Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently lon
    12·1 answer
  • Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burn
    13·1 answer
  • c Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement. Hint: Call FindMax() twice in a
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!