SUM OF INDIVIDUAL DIGITS - C-Tutorial

Latest

Monday, 26 September 2016

SUM OF INDIVIDUAL DIGITS

/* SUM OF INDIVIDUAL NUMBERS */

#include<stdio.h>
#include<conio.h>

main()
{
int a,n,sum=0;
clrscr();
printf("\n Enter n value:");
scanf("%d",&n);
while(n>0)
{
a=n%10;
sum=sum+a;
n=n/10;
}
printf("\n The sum of individual digits is: %d",sum);
getch();
}

No comments:

Post a Comment