We are going to add all digits in the number that is input by user through
 this program. 
 
 Program

 #include<stdio.h> 

 #include<conio.h>

 void main()

 {

 int n,rem,sum=0;

 printf("Enter the number:");

 scanf("%d",&n);

  do {

      rem=rem%10;

      n=n/10;

      sum=sum+rem;

       } while(n>0);

   printf("Sum of digits of number entered by user:%d\n",sum);

  }

 Output:








Post a Comment

Previous Post Next Post