EDUTAINMENT
EDUCATION + ENTERTAINMENT = EDUTAINMENT
Pages
Home
C Programs
C++Programs
Java Programs
Data Structures
Python Programs
HTML Programs
Download Books
GATE PAPERS
Auto AdSense
Saturday, 15 November 2014
C Program to find the Sum of Digits
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,num,x,sum=0;
printf("Enter a number=");
scanf("%d",&n);
while(n>0)
{
x=n%10;
sum=sum+x;
n=n/10;
}
printf("Sum of digits of a number=%d",sum);
getch();
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment