Write a C program to find the sum of individual digits of a positive integer.

Program Code:
#include<stdio.h>
void main()
{
int n,d,s=0;
printf("\n Enter a number:");
scanf("%d",&n);
while(n!=0)
{
d=n%10;
n=n/10;
s=s+d;
}
printf("sum of individual digits=%d",s);
}

Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: