/* Find The Sum Of Digits Of A Given Number */
For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.
For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.
#include <stdio.h>
#include <conio.h>
void main()
{
int number,sum=0,last_digit;
clrscr();
printf("Enter a number");
scanf("%d",&number);
while(number>0)
{
last_digit=number%10;
sum=sum+last_digit;
number=number/10;
}
printf("The sum of digits of given number is: %d",sum);
getch();
}
No comments:
Post a Comment