C Program to find sum of digits of a number - c programs
//C Program to find sum of digits of a number
//C Program to find sum of digits of a number
#include<stdio.h>
#include<conio.h>
void main()
{
int a,n,sum=0;
clrscr();
printf("Enter the number"); scanf("%d",&a);
do
{
n=a%10;
sum=sum+n;
a=a/10;
}
while(a=0);
printf("The sum of digits of the number %d is %d",a,sum);
getch();
}
#include<conio.h>
void main()
{
int a,n,sum=0;
clrscr();
printf("Enter the number"); scanf("%d",&a);
do
{
n=a%10;
sum=sum+n;
a=a/10;
}
while(a=0);
printf("The sum of digits of the number %d is %d",a,sum);
getch();
}
No comments:
Post a Comment