So how does the code tell the input has ended? is this based on scanf() inputs or file based inputs.
The exact words the problem says is: "For each line of the input, your correct program should output the integer value of the sum in separate lines for each pair of values of N & A."
Like right now this is the code I have after your last post:
Code:
int main(int argc, char *argv[])
{
int total,n,a,i,sum=0;
while (scanf(" %d %d ", &n, &a) == 2) {
if (total > -1) putchar('\n');
for(i=1; i<=n; i++)
{
int calc,x,final_a = a;
for(x=1;x<i;x++)
{
final_a = final_a * a;
}
calc = i * final_a;
sum = sum + calc;
}
total++;
printf("%d",sum);
}
system("PAUSE");
return 0;
}
I enter for example
3 3
4 4
the output is:
102
nothing else.
I still dont really understand what the problem means by that sentence. Do you think it wants me to figure out how many inputs they are going to give the app or is it ONLY 2 and ALWAYS 2?
Thanks!