#include#include void sum(int n){int sum,n1;sum=0;for(;n>0;){n1=n%10; sum=sum+n1;n=n/10; }printf("sum of digits=%d",sum);}void main(){int x;clrscr();printf("enter the value of n");scanf("%d",&x); sum(x);getch();}
No comments:
Post a Comment