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
omeli [17]
3 years ago
14

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

of this program, using the while, do-while, and for loops.
Computers and Technology
1 answer:
Alex17521 [72]3 years ago
7 0

Answer:

Explanation:

I'm going to write three examples in C language:

int main() {

   int n, i, sum = 0;

   printf("Enter the number: ");

   scanf("%d", &n);

   for (i = 1; i <= n; ++i) {

       sum += i;

   }

   printf("Sum = %d", sum);

   return 0;

}

int main() {

   int n, i, sum = 0;

   printf("Enter a number: ");

   scanf("%d", &n);

   i = 1;

   while (i <= n) {

       sum += i;

       ++i;

   }

   printf("Sum = %d", sum);

   return 0;

}

int main() {

   int n, i, sum = 0;

   do {

       printf("Enter a number: ");

       scanf("%d", &n);

   } while (n <= 0);

   for (i = 1; i <= n; ++i) {

       sum += i;

   }

   printf("Sum = %d", sum);

   return 0;

}

You might be interested in
Es el conjunto de manifestaciones materiales, intelectuales y espirituales que distinguen a un pueblo a)Civilización b)Cultura c
GREYUIT [131]

Answer:

a)Civilización

Explanation:

3 0
3 years ago
Explain how can we determine that where is the strength of magnetic force maximum in a
snow_lady [41]

Answer:

by making a experiment

Explanation:

8 0
3 years ago
How did domestication of maize make the city of tenochtitlan possible?
umka21 [38]

The farming of maize began in Mesoamerica in 6000 B.C. The domestication of maize made the city of Tenochtitlan possible by providing the Aztecs the ability to feed millions. Unlike the corn that is known today, the early maize had tiny cobs but dramatically became bigger and more nutritious as time passed.


3 0
3 years ago
Read 2 more answers
Write an if statement that prints the message “Application accepted” if the variable workExperience is greater than or equal to
katovenus [111]
If workExperience >= 2 or CollegeDegree is true:
print “Application accepted”
else:
print “Application denied”

4 0
3 years ago
Read 2 more answers
Dns (domain name system) servers translate all domain names into _____. hypermedia cookies ip addresses proxy servers
sweet-ann [11.9K]
<span>Dns (domain name system) servers translate all domain names into </span>ip addresses
4 0
3 years ago
Other questions:
  • Tower defense is included under which genre of game
    15·2 answers
  • The version of Windows that first provided networking capabilities was _____.
    12·2 answers
  • Describe what is meant by the following:
    14·1 answer
  • If you decide to get married, a trade-off would be that you have to give up being single.
    12·2 answers
  • The graph shows that sixty-eight percent of students think cyberbullying is a problem. One hundred human stick figures are shown
    14·2 answers
  • Which of the following lists the proper order of the categories of the SOC system from general to specific?
    11·1 answer
  • Write a program Gas.java that computes and displays the price a person will pay for gas at the gas station. The program takes th
    12·1 answer
  • Match the following.
    8·1 answer
  • In which drawer do you find blocks that allow you to use the A and B buttons on your micro:bit?
    13·2 answers
  • 12. In Justify the text is aligned both to the right and to the left margins, adding extra space between words as necessary *
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!