Computer Science, asked by lufynrt103, 1 year ago

Find the sum of squares of individual digits of a number 'sqdnumber' and store the sum in variable 'sqdNumber_result'. E.g. if the number is 234, the sum is computed as (22 + 32 + 42 = 4 + 9 + 16 = 29)

Answers

Answered by nitish8089
4

          .....code.....

import java.util.Scanner;

public class Program

{

   public static void main(String[] args) {

       Scanner sc=new Scanner(System.in);

       int sqdNumber=sc.nextInt();

       int sqdNumber_result=0;

       int temp=sqdNumber;

       do{

           int x=temp%10;

           sqdNumber_result+=(x*x);

           temp/=10;

       }while(temp>0);

       System.out.println("the sqdNumber_result of the no."+sqdNumber+" is "+sqdNumber_result);

   }

}

Similar questions