Code for PROGRAM USING WHILE LOOP TO DO SUM OF DIGITS OF THE NUMBER. NO IS - 12345 ANS IS 15 in C Programming
#include <stdio.h>
#include <conio.h>
#include<math.h>
void main()
{
long n,j,sum = 0;
clrscr();
printf("Enter the No :- ");
scanf("%ld",&n);
printf("\n");
while(n>0)
{
j = n%10;
sum += j;
n /= 10;
}
printf("The sum of digit is = %ld", sum);
getch();
}
/*
********
OUTPUT
********
Enter the No :- 678
The sum of digit is = 21
*/