Advertisement
valve2

this program uses a count controlled loop to count the sum of 5 entered digits

Jan 19th, 2023 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | Source Code | 0 0
  1. // this program uses a count controlled loop to count the sum of 5 entered digits
  2. #include <stdio.h>
  3. int counter, num, total;
  4. int main(void) {
  5.     printf("This program calculates the sum of five numbers \n\n");
  6.    
  7.     for (counter = 1; counter <= 5; counter ++) {
  8.         printf("Enter a number\n");
  9.         scanf_s("%d", &num);
  10.         total = num + total;
  11.     }
  12.     printf("The sum of the five numbers that you entered is %d \n", total);
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement