Friday 23 March 2012

Program for finding the sum of digits of a five digit number.

Q: Write a 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;

 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("\nThe sum of its digits is %d.",s);
 printf ("\n\nDo you want to continue?(y/n):-  ");
 scanf("%c",&c);
 if (c=='y')
  goto repeat;
 getch();
}
Output:







1 comment:

  1. Videoslots videoslotsvideos.com | YouTube
    Videoslots videoslots videoslots youtube mp4 videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots videoslots

    ReplyDelete