Here we gave easiest understanding program to you.
All programs easy to learn every person.
And all subjects are compulsory in BCA.
Powered by Blogger.

Followers

Monday, 16 September 2019

Sum of individual number in C

0 comments

/* C Program to find the sum of individual digits of given no. */ 

           


#include<stdio.h>      
int main()    
{                                  
  int n,r,sum=0;                       
  printf("Enter a  no:");             
  scanf("%d",&n);        while(n>0)    
  {                                
r=n%10;    
sum=sum+r;  
n=n/10;  
  }                                
printf("Sum is %d",sum);                   

 return 0;                          

}    
 
     
INPUT/OUTPUT :

Enter a  no:123
Sum is 6

No comments:

Post a Comment