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
What is the importance of human flourishing to science and technology?​
nadya68 [22]

Explanation:

:*):*):*)*)*:)*:)*:*)*:**:*)*:)*:)*:*):*)*P:)*:*):*)

:*

):*

)*:

)*:*

):*):*)*:*):*)*:*):*):*):)*:*):*):*):*)

:*):*)

6 0
3 years ago
What is the role of memory in a computer​
Anuta_ua [19.1K]

Answer:

Computer random access memory (RAM) is one of the most important components in determining your system's performance. RAM gives applications a place to store and access data on a short-term basis. It stores the information your computer is actively using so that it can be accessed quickly.

5 0
3 years ago
Nonword passwords are vulnerable to a ________ attack in which the password cracker tries every possible combination of characte
Stels [109]
That would be your name and then you date of birth 
6 0
3 years ago
Read 2 more answers
Given the following code, what will it display?
trapecia [35]
Number#4 = 55 ; start counting from 0
4 0
4 years ago
Read 2 more answers
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? Ex
Delicious77 [7]

Answer: the employment demand would increase.

Explanation:

Several factors affect the employment demand especially in a field as peculiar as engineering, the cumulative build up of unemployed graduates and the skill set required to fit into the present working structure is also of Paramount importance. The evaluation method for recruitment seeks to function based on this rationale by selecting a few amongst many.

8 0
3 years ago
Other questions:
  • Before installing any software, it's always important to back up your system and to create a BLANK, which enables you to go back
    6·2 answers
  • The term BIOS stands for
    6·1 answer
  • 2x + 3y = 11<br>y = x-3​
    8·2 answers
  • #Write a function called hide_and_seek. The function should #have no parameters and return no value; instead, when #called, it s
    7·1 answer
  • b) Derive the logic expressions for the incrementor and 7-sgement decoder. Since software can perform gate-level optimization, y
    7·1 answer
  • Suppose the daytime processing load consists of 65% CPU activity and 35% disk activity. Your customers are complaining that the
    15·1 answer
  • What are possible penalties if a designer is caught breaking copyright laws?
    13·1 answer
  • 3. Comparing the Utopian and dystopian views of Technology according to Street (1992) which one in your view is more applicable
    14·1 answer
  • ____ loses data when it stops receiving electrical power.
    10·1 answer
  • which of the following is acomputer program that detects, prevents. and takes action sto deactivate or remove malicious programm
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!