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
The three Fs of product design are form, fit and
Rudiy27

Answer: Function

Explanation: <em>"Function is a criterion that is met when the part performs its stated purpose effectively and reliably. In an electronics product, for example, function can depend on the solid-state components used, the software or firmware, and quite often on the features of the electronics enclosure selected. Poorly placed or sized ports and misleading or missing labeling are two of the most common ways in which an enclosure can fail the function criterion."</em>

5 0
3 years ago
Read 2 more answers
The _______ number system allows digital devices to represent virtually any number simply by using 0s and 1s.â
zhuklara [117]
The answer is <span>Digital data 

</span>
4 0
3 years ago
Which is the most effective way to demonstrate being prepared for an interview
postnew [5]

Answer:

Companies want people who know more about them and rather have someone who is interested in the company than someone who is just looking for a way to get payed.

Explanation:

7 0
3 years ago
What protocol suite below is the most commonly used protocol for local area network (lan) communication?
grandymaker [24]
Answer TCP/IP is the most common protocol in Local Area Networks.
3 0
3 years ago
The bullets button is available on the home tab of the ribbon in the ____ group.
Helga [31]
The bullets button is available on the home tab of the ribbon in the ____ group.
Paragraph
7 0
3 years ago
Other questions:
  • Put these steps for managing your study time in chronological order. 1 set aside the same time each day 2 Identify the best time
    14·1 answer
  • To create a formula in______, you would first click in one of the cells​
    14·2 answers
  • THIS IS PYTHON QUESTION
    11·1 answer
  • The growing network of physical objects that will have sensors connected to the Internet is referred to as the ________.
    13·1 answer
  • The major difference between a template and another document is in _____.
    7·1 answer
  • How to beat level 50 in give up robot 2
    5·1 answer
  • Use the drop-down menus to complete each statement. Two main versions of Outlook are the desktop app and the app. The has limite
    15·2 answers
  • What is the difference between auto fill and fill handle ?​
    7·1 answer
  • John has recently retired from an administrative, yet technical job which he held for 40 years. He decided to pursue a life-long
    11·1 answer
  • What is the difference between referential and entity integrity
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!