e.g. initially the variable value is declared 0. Now within the loop I keep a parameter n, the value of which will be entered by me. say first time I enter n=6. Then the value 0 becomes 6. If I enter 5 next, the valu will become 11.
But practically, due to error in position of declaration of the initial value of the variable, after each iteration, variable value is becoming zero again...
Here is how far I came...
Code:
#include<stdio.h>
#include<conio.h>
int inc(int num, int n)
{
num=num+n;
return(num);
}
void main()
{
int num,n,i;
num=0;
for(i=0;i<20;i++)
{
printf("\nEnter n=");
scanf("%d", &n);
printf("\nNew value of num=%d\n", inc(num,n));
}
getch();
}
Please help...thanks in advance...
Cheers....


