#include<stdio.h>void main(){int digit_1,digit_2,digit_3,digit_4,digit_5,sum,number,n;printf("Enter a five digit number");scanf("%d",&number);n=number;digit_1=n%10;n=n/10;digit_2=n%10;n=n/10;digit_3=n%10;n=n/10;digit_4=n%10;n=n/10;digit_5=n;sum=digit_1+digit_2+digit_3+digit_4+digit_5;printf("sum of digits=%d\n",sum);getch();}
Tuesday, June 28, 2011
TO FIND THE SUM OF DIGITS IN A FIVE DIGIT NUMBER
Subscribe to:
Post Comments (Atom)