Code:
#include <stdio.h>
main()
{
int p,N[100] = {0},d,c,E=0;
printf("Input a number: ");
scanf("%d",&p);
for(d=1,c=0;d<=p;d++)
{
if(p%d==0)
{
N[c]=d;
c++;
}
}
c=0;
while(N[c]!=0)
{
E=E+N[c];
c++; // see here since you are not incrementing c in your code, the while loop becomes an infinite one.
}
printf("\n%d",E);
}
its something common for beginners. you take care of the important part(to find the sum or the product or whatever but forget to do the smaller steps.) increment the index c in the while loop until there is a zero..hope it helps!!
but im not getting the right answer when i input 20 the answer should be 1+2+5+10+20=38.
a number is a factor of itself you missed that point there..
by the way initialize E to zero...