#include<stdio.h>
void main()
{
int Num,Sum=0,Digit;
printf("Enter a Four Digits Number\n",&Num);
scanf("%d",&Num);
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
printf("\nSum of Digits are :-- %d\n",Sum);
}
void main()
{
int Num,Sum=0,Digit;
printf("Enter a Four Digits Number\n",&Num);
scanf("%d",&Num);
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
Digit=Num%10;
Num=Num/10;
Sum+=Digit;
printf("\nSum of Digits are :-- %d\n",Sum);
}
Enter a Four Digits Number
1245
Sum of Digits are :-- 12
No comments:
Post a Comment