4
Reply

Print sum of digits.

saloni seth

saloni seth

12y
887
0
Reply

    Snippet like this t=0; b=a%10; a=a/10; t=t b;

    #include #include void main() { int num=0; int sum=0; int reminder=0;clrscr(); printf("\n enter No to calculate sum of dgit"); scanf("%d",&num) while(num>0) {reminder=num%10; sum=sum+reminder; num=num/10; } printf("Sum of digit=%d",sum) getch();}

    while(num){ r=num%10; num=num/10; sum=sum+r; }

    while(num){r=num%10;num=num/10;sum=sum+r;}