I am beginner in C programming and I want to improve this program by asking the user to enter an integer N and then the program make the sum of its digits and if the result of this sum is greater than a one digit we are remaking the sum of these digits.
example: N= 123456 -----> S= 1+2+3+4+5+6 ---------> S= 21 ------------> S=3
#include <stdio.h>
main()
{
int T[50];
int N;
int I;
long S;
printf("D (max.50) : ");
scanf("%d", &N );
for (I=0; I<N; I++)
{
printf("E %d : ", I);
scanf("%d", &T);
}
printf("T :\n");
for (I=0; I<N; I++)
printf("%d ", T);
printf("\n");
for (S=0, I=0; I<N; I++)
S += T;
printf("Sum : %ld\n", S);
return 0;
}
Thanks in advance ;)