------------------------------------------------------------------------------
MC logo
Adding In C
[^] CSc 314 Assignment 2
------------------------------------------------------------------------------
[CSc 314 Assignment 1] [CSc 314 Assignment 2]
[Adding In C] [A2 Key]
cadd.c
#include <stdio.h>

main()
{
        int tot = 0;

        while(1) {
                /* Prompt for and read the input number. */
                int num;
                printf("Enter a number (-1 to quit): ");
                scanf("%d", &num);

                /* Done at -1. */
                if(num == -1) break;

                /* Add to the total and display. */
                tot += num;
                printf("  Total ==> %d\n", tot);
        }

        printf("All done.\n");
}