title: C program to print sum of squares of digits of a given number?
body: <p>I want to write a c program that prints the sum of the squares of a given number.
  For example, if the given number is 456, the output would be 4^2+5^2+6^2=16+25+36=77.</p>
  
  <p>So i have written this code and i want to know why it doesn't work if the user gives a number like 100,101,102 or 200,300 etc. It works fine for other numbers. I guess it has something to do with the dowhile loop. Please help me.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;math.h&gt;
  main()
  {
   int n,t=0,r,q;
   printf("Enter the number to be tested: ");
   scanf("%d",&amp;n);
   q=n;
   do
   {
        r=q%10;
        t=t+pow(r,2);
        q=q/10;
   }
   while(q%10!=0);
   printf("%d",t);
   getch();
  
  
  }
  </code></pre>