Displaying Source Code(s)
|
|
Program for finding the sum of digits of a five digit number.
--------------------------------------------------------------------------------
#include <stdio.h>
#include <conio.h>
void main()
{
int n,o,p,q,r,s;
char c;
clrscr();
repeat: s=0;
printf("
Enter 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 ("
Do you want to continue?(y/n):- ");
scanf("%c",&c);
if (c=='y')
goto repeat;
getch();
}
|
|
|