Answer :
#include<stdio.h> //header file contains the function,decleraction and macro defination of key words used in code.
int main ()
{
int num,num1,sum=0; //adressing the variables
printf("Enter the number you want "); //output
scanf("%d",&num);
while (num!=0) // using while loop
{
num1=num%10; // it will store the last number
sum=sum+num1; //it will add it
num=num/10; // it will remove the last digit
}
printf("The sum of the digits is %d",sum); //output
}
Output :
0 Comments