void main()
{
int num=123456;
int sum=0;
for(;num > 0;sum+=num%10,num/=10); // This is the "single line".
printf("\nsum = [%d]\n", sum);
}
{
int num=123456;
int sum=0;
for(;num > 0;sum+=num%10,num/=10); // This is the "single line".
printf("\nsum = [%d]\n", sum);
}
No comments:
Post a Comment