Compile and run the code below in your own C environment.
#include <stdio.h>
int main(void) {
int i, n, sum;
printf("Please enter a positive integer: ");
scanf("%d", &n);
sum = 0;
for(i=1; i<=n; i++);
sum += i;
printf("The sum from 1 to %d equals %d.", n, sum);
return(0);
}
When your program performs correctly you’ll be given a keyword to enter in Canvas.
Compile and run the code below in your own C environment.
#include <stdio.h>
int main(void) {
int i, n;
int sum = -1;
printf("Please enter a positive integer: ");
scanf("%d", &n);
printf("You entered %d.\n", n);
for(i=1; i<=n; i++)
sum += i;
printf("The sum from 1 to %d equals %d.", n, sum);
return(0);
}
When your program performs correctly you’ll be given a keyword to enter in Canvas.