Activity 4.7. Adding User Input.
Please write a program that adds integers, entered by the user.
First, ask the user to enter the number of integers they wish to add. Next, use a
for-loop that runs the desired number of times, and in which you continually ask the user to enter another number that then gets added to the sum.
When the loop terminates, print the result to the screen.
Here is a sample session, with simulated user input in bold:
How many numbers do you wish to add? 5 Please enter number 1: 7 Please enter number 2: 13 Please enter number 3: 4 Please enter number 4: -3 Please enter number 5: 9 The numbers you entered add up to 30.
Compile and run the code below in your own C environment.
#include <stdio.h>
int main(void)
{
int i; /* loop counter */
int total; /* holds the sum */
int num; /* individual numbers entered by the user */
int count; /* hold number of numbers the user wishes to add */
printf("How many numbers do you wish to add: ");
scanf("%d", &count);
/* Write your code here. */
printf("The numbers you entered add up to %d.", total);
return(0);
}

