Vision and dreams are the blueprints of soul and achievements.
-Mohammed Ahmed F

Program to find the sum of given integer

#include<stdio.h>

void main()
{
long num, temp, digit, sum = 0;
printf("Enter the number\n");
scanf("%ld", &num);
temp = num;
while(num > 0)
{
  digit = num % 10;
  sum  = sum + digit;
  num /= 10;
}
printf("Given number =%ld\n", temp);
printf("Sum of the digits %ld =%ld\n", temp, sum);
}

OUTPUT:


Enter the number 235
Given number = 235
Sum of the digits 235=10

Share this

Related Posts

Dear User,

Thank you for your comment. Hope you like this blog. Kindly share us on Social Media so others can be updated.

-Chief Administrative Officer.