Skip to main content

Sum of digits of a number down to a single digit.

PROCEDURE:-

      1.enter integer value n
      2.repeat  step 3 to 8 until n is greater than 9
      3.set sum to 0
      4.repeat  step 5 to 7 until n is greater than
      5. find the modulo 10 for n and store result in r
      6.add r to previous sum
      7. find new value of n by dividing it by 10
      8 set  n to sum
      9. print sum


CODE:-

#include<stdio.h>
void main()
{
  int n,m,sum,r;
  printf(“enter value for n”);
  scanf(“%d”,&n);
  m=n;
  while(n>9)
  {
    sum=0;
    while(n>0)
     {
       r=n%10;
       sum=sum+r;
       n=n/10;
     }
   n=sum;
}
printf(“sum of %d down to single digit is %d”,m,sum);
}


Input:- enter value for n 137
Output:- sum of 137 down to single digit is 2
 

Comments

Popular posts from this blog

Future Mouse-Evo Mouse

New evolution of the Mouse. In 1980's round ball mouses are invented, then technology introduced Optical mouses. Now upcoming Mouse is named as Evo mouse . No more movement of your hands on placing a physical mouse,   Your finger is the pointer . You can use this mouse on any Flat Surface and also it requires very little space. This mouse contains a Power button on the top, Mini USb port . It works with the help of bluetooth and input is taken by the sensor. View this Video to know the functionality of   EvoMouse

Hide your IP address with Proxy servers

The most common method to Hide your IP address is to use a PROXY server. Proxy server is a computer network service that provides an indirect connections between other computer networks. By using this proxy sites we can access any website with out revealing our IP address. This is the best method to keep your IP address secure. Here is the free proxy server website link.  http://www.freeproxyserver.ca/     We need to type the URL of such as (www.facebook.com) in the box given in the site, then we can browse it with out providing our IP address

Speed Up Your RAM

Speed up your RAM speed by using this technique... 1. Click  Start button Picture  of the Start button 2. Click  Control Panel 3. Choose  System and Maintenance  and then click  System . 4. In the left pane, click  Advanced system settings . 5.On the Advanced tab, under Performance, click  Settings . 6. Click the Advanced tab, and then, under Virtual memory, choose Change. 7. Click  Custom  to change the Initial size (MB) and Maximum size. See the hot tip above. Remember to choose the drive you would like to use to increase the virtual memory. In most cases it usually your C: Drive. You can set the initial size and maximum size after clicking the Custom size check box.Remember its better to keep the Virtual memory values the same. Also having enough available space is absolutely necessary for your virtual memory and RAM to function properly.  In Windows XP 1.Click Start, and then click  Control Pane...