229k views
1 vote
Follow these instructions to complete your assignment: 1. Write a flowchart and C code for a program that does the following: - Use a for() loop, starting at 100 and ending at 200 - note: there is no user input with this program. - Use an accumulating total statement to keep a running total of the numbers between 100 and 200 - Display the grand total of the values added together

1 Answer

0 votes

Final answer:

Write a C program with a for loop starting at 100 and ending at 200, which calculates the running total of the numbers. The sum is stored in a variable named 'total' which is printed at the end.

Step-by-step explanation:

To complete your assignment and create a C program that calculates the running total of numbers between 100 and 200 using a for loop, you can follow this example:

#include
int main() {
int total = 0;
for(int i = 100; i <= 200; i++) {
total += i;
}
printf("The grand total is: %d\\", total);
return 0;
}

This code initializes a variable total to keep track of the sum. It then uses a for loop to add each number from 100 to 200 to the total. Finally, it prints out the grand total after the loop finishes. Remember, in C language, the for loop continues to iterate as long as its condition is true, and in this example, the condition is that i must be less than or equal to 200.

User Ravisuhag
by
7.7k points