Sunday, September 18, 2011

WAP to find the sum of the digits of a five number digit number



/*
  Name: WAP to find the sum of the digits of a five number digit number
  Author: Parveen Malik
  Date: 18/09/11 01:04
*/


#include<stdio.h>
#include<conio.h>
int main(void)

    long num,rem,temp;
    int sum=0;
    printf("Enter any five digit number : ");
    scanf("%ld",&num);
    temp=num;
    while(num>0)
    {
                rem=num%10;
                num=num/10;
                sum+=+rem;
                }
                printf("Sum of %ld\'s digit is = %d",temp,sum);
                getch();
                return 0;
                }


OUTPUT :

0 comments:

Post a Comment