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
Katen [24]
3 years ago
13

Write a program that reads numbers from scanf (keyboard) and then sums them, stopping when 0 has been entered. Construct three v

ersions of this program, using the while, do-while, and forloops.
Computers and Technology
1 answer:
almond37 [142]3 years ago
4 0

Answer:

For loop Version:

#include <stdio.h>

int main()

{

   int number, sum = 0;

   printf("Enter a positive integer: ");

   scanf("%d", &number);

   

   for (int i = 0; i <= number; i++) {

       if(number == 0)

           break;

       sum += number;

       

       printf("Enter a positive integer: ");

       scanf("%d", &number);

   }

   printf("Sum is: %d", sum);

   return 0;

}

- - - - -

While Loop Version:

#include <stdio.h>

int main()

{

   int number, sum = 0, i = 0;

   printf("Enter a positive integer: ");

   scanf("%d", &number);

   

   while (number != 0) {

       sum += number;

       

       printf("Enter a positive integer: ");

       scanf("%d", &number);

   }

   printf("Sum is: %d", sum);

   return 0;

}

Do-while Loop Version:

#include <stdio.h>

int main()

{

   int number, sum = 0, i = 0;

   

   do {

       printf("Enter a positive integer: ");

       scanf("%d", &number);

       

       sum += number;

       

   } while (number != 0);

   printf("Sum is: %d", sum);

   return 0;

}

Explanation:

- Initialize the variables

- Ask the user for the numbers until the user enters 0

-  Calculate and print the sum

You might be interested in
Decision trees are onlyapplicable to problems under certainty.<br> True<br> False
lions [1.4K]

Answer: False

Explanation:Decision tree is the tree like structured flowchart which is used for the evaluation of the possible outcomes or result of the particular problem. It usually has two or more branches as the the result node . Decision tree are applicable to many problems for solving it. So, decision trees is not only applicable on certainty problems but also on other problems as well. Therefore the given statement is false.

6 0
3 years ago
Who wants to join my zoom after school 23456+4567
tensa zangetsu [6.8K]
Meeeeeeeeeeeeeeeeeeee
5 0
3 years ago
Out of a list of the values 2, 45, 18, 22, 8, and 37, what result would the MAX function return?
Vika [28.1K]
37 most likely.
No programming language is specified, and you didn't put what the function is, so assuming it's already implemented, MAX should display the highest number.
8 0
3 years ago
Read 2 more answers
_____ targeting techniques increase the effectiveness of banners, rich media, and video ads.
Delvig [45]

Banner, rich media, and video ad effectiveness is increased through behavioral targeting strategies.

<h3>What are Behavioral targeting techniques?</h3>
  • A marketing strategy called "behavioral targeting" makes use of data about web users to enhance advertising campaigns.
  • The method entails obtaining information on a potential customer's web browsing and purchasing habits from a range of sources.
  • In order to assess which advertisements and messages will be most effective with a certain audience, behavioral targeting is used.
  • To launch personalized marketing, it makes use of behavioral data, such as what users do or don't do in your app, on your website, or with your campaigns.
  • An illustration of behavioral targeting would be if a customer frequently visited a website with evaluations of thermometers for home use or conducted a search for thermometers, then went to a website for the producer of thermometers.

To learn more about  Behavioral targeting techniques, refer to:

brainly.com/question/28025161

#SPJ4

4 0
2 years ago
Terri brought a magazine for $5, and 2 bottles of nail polish. Write an expression to represent the total amount she spent. Then
kykrilka [37]

The expression that can be used to represent the total amount Terri spent is C = 5 + 2x

<h3>How to write equation</h3>

  • Cost of magazine = $5
  • Number of nail polish bought = 2 bottles

let

x = cost of each nail polish

Total cost, C = magazine + nail polish

C = 5 + 2x

  • If cost of each nail polish = $3

C = 5 + 2x

= 5 + 2(3)

= 5 + 6

C = $11

Learn more about equation:

brainly.com/question/16863577

3 0
2 years ago
Other questions:
  • Select the correct answer.
    7·2 answers
  • ​a(n) ____ is a communications device that connects a communications channel such as the internet to a device such as a computer
    11·1 answer
  • What might be one reason why a stock becomes more valuable over time
    5·1 answer
  • A defined set of standards that computers must follow in order to communicate properly is known as a
    13·2 answers
  • Frank develops a questionnaire for his study on Internet dating. One of his questions asks, "How do you feel about Internet dati
    14·2 answers
  • Project manager George is defining project management to his team. How should he define project management in one sentence?
    7·1 answer
  • A string variable can hold digits such as account numbers and zip codes.<br><br> FALSE<br><br> TRUE
    14·1 answer
  • State three reasons why users attach speakers to their computer​
    8·1 answer
  • Make the list of menu icon in MS Excel<br>​
    8·1 answer
  • Hypertext enables you to navigate through pieces of information by clicking the __________, that connect them.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!