#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
int a,b,sum=0;
printf("enter the number");
scanf("%d",&a);
while(a>0)
{
b=a%10;
a=a/10;
sum=sum+b;
}
printf("the sum of digits of a number %d",sum);
getche();
}
#include<math.h>
#include<conio.h>
void main()
{
int a,b,sum=0;
printf("enter the number");
scanf("%d",&a);
while(a>0)
{
b=a%10;
a=a/10;
sum=sum+b;
}
printf("the sum of digits of a number %d",sum);
getche();
}
No comments:
Post a Comment