8-Write a C program to add the entered digit’s number.

Program: 8

Write a C program to add the entered digit’s number.

#include
#include
void main()
{
    int num, a, b, c, d, e, sum;
    printf("Enter the number of five digits: ");
    scanf("%d", &num);
    a=num/10000;
    num=num%10000;
    b=num/1000;
    num=num%1000;
    c=num/100;
    num=num%100;
    d=num/10;
    num=num%10;
    e=num;
    sum=(a+b+c+d+e);
   printf("The sum of five digits is: %d", sum);
    getch();
}
Output
Enter the number of five digits: 43234

The sum of five digits is: 16

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.