Sum of Digits of a number using while Loop

/* Write a program to find Sum of Digits of a number using while Loop */

#include<stdio.h>
#include<conio.h>
void main()
{
int sum=0,d;
long n ,t;
clrscr();
printf("\n Enter any Positive Number ");
scanf("%ld",&n);
t=n;
while(t>0)
{
d = t % 10 ;
t = t / 10 ;
sum = sum + d;
}
printf("\n Sum of digit of %ld = %d",n,sum);
getch();

}

Who's online

We have 11 guests and one member online

About Us

Harsimran Singh

Hello

This website is a special gift for Programming Lovers , which want to learn basic Programming Languages and want to develop there skills Read More....

Our work

Find Us

This email address is being protected from spambots. You need JavaScript enabled to view it.

Harsimran Singh(Facebook)

Harsimran Singh(about.me)

Harsimran Singh(G+)