fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int num,r1,d1,d2,r2,sum;
  5. printf("enter a number:");
  6. scanf("%d",&num);
  7. while(num>99&&num<1000)
  8. {
  9. r1=num/100;
  10. d1=num%10;
  11. d2=r1/10;
  12. r2=r1%10;
  13. sum=d1+d2+r2;
  14. }
  15. printf("sum of three digits=%d",sum);
  16. return 0;
  17. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
enter a number:sum of three digits=0