Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks

Thursday, 15 November 2012

Sum of the given number digits using in C program language examples?

Sum of the given number,Sum of the given number in C,Sum of the given number in C program language,C language sum of the number,sum the number in C,Sum of the given number using in C program language,sum of the given number digits using C,using C sum the given number,C language sum program,sum of the number in C program language,sum the number


Sum of the given number in C:-


              Suppose we enter the number 1234,The sum of the 1234 is 1+2+3+4=10.
      Program is developed at below for this logic.

                   #include<stdio.h>
                   main()
                   {
                           int n,rem,sum=0;

                                printf("Enter the number\n");
                                scanf("%d",&n);

                                  while(n>0)
                                  {
                                        rem = n%10;
                                        sum = sum + rem;
                                         n = n/10;
                                   }
                           printf("After summing the numbers %d\n",sum);
                    }

              Output:-
                             
                                   Enter the number
                                       1234
                                    After summing the number 10
 

1 comments: