C Source Codes List | Source Code Home
Program : Program for finding the sum of digits of a five digit number.
/* Program for finding the sum of digits of a five digit number */
#include
#include
void main()
{
int n,o,p,q,r,s;
char c;
clrscr();
printf("\t\t\tWELCOME TO THE PROGRAM SIR/MADAM\n\n\n");
repeat: s=0;
printf("\n\nEnter a five digit no.:- ");
scanf("%d",&n);
o=n%10000;
p=o%1000;
q=p%100;
r=q%10;
s=(n/10000)+(o/1000)+(p/100)+(q/10)+r;
printf("The sum of its digits is %d.",s);
fflush(stdin);
printf ("\n\nDo you want to continue?(y/n):- ");
scanf("%c",&c);
if (c=='y')
goto repeat;
printf("\n\n\n\n\n\t\t\tHAVE A NICE DAY! BYE.");
getch();
}
C Source Codes List | Source Code Home
|
|