Mega Code Archive

 
Categories / C / Data Type
 

Adds up 5 numbers

#include <stdio.h> int main() {     int total = 0;     int current;     int counter = 0;     char line[80];     while (counter < 5) {         printf("Number? ");         fgets(line, sizeof(line), stdin);         sscanf(line, "%d", &current);         total += current;         ++counter;     }     printf("The grand total is %d\n", total);     return (0); }