CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,sum=0,n;
clrscr();
printf("Enter any integer value ");
scanf("%d",&num);
while(num>0)
{
n=num%10;
sum=sum+n;
num=num/10;
}
printf("Sum of digits is = %d",sum);
getch();
}
|
CODING |
|
OUTPUT |
For any query or suggestion please comment below...
No comments:
Post a Comment