Okay, how does this look?
Code:
int countTotal;
int countingIndex;
int xValue;
int sum=0;
printf("What is the total number of X's?: ");
scanf("%d", &countTotal);
for(countingIndex=1; countingIndex<=countTotal;countingIndex++){
printf("For X%d, what is the value of X?: ", countingIndex);
scanf("%d", &xValue);
sum = sum+xValue;
}
printf("The total sum of X's = %d",sum);
return 0;
I ran it and it actually works so i'm guessing my statement inside the for loop to find the sum is valid. Is there a better way to write this?