#include<stdio.h>
#include<conio.h>
/* take number from user three digits and print the sum of its digits example 223=> 2+2+3=6 */
void main()
{
int sum, num, Rem, digit1, digit2, digit3;
clrscr();
printf("enter number");
scanf("%d",&num);
Rem=num%100;
digit1=num-Rem;
digit1=digit1/100;
digit3=Rem%10;
digit2=Rem-digit3;
digit2=digit2/10;
sum=digit1+digit2+digit3;
printf("%d",sum);
getch();
}
No comments:
Post a Comment