Computer Science, asked by lipidutta1977, 9 days ago

Write a Java program to input a positive integer and calculate and display the norm of that number. The norm of a number is the square root of the sum of the squares of all the digits of the number, Example: The norm of 68 is 10. 6 x 6 + 8 x 8 = 36 + 64 = 100 V100= 10 ​

Answers

Answered by gaminglinda271
1

The following program segment calculates the norm of a number, norm of a 

number is square root of sum of squares of all digits of the number.

 Example: The norm of 68 is 6×6 + 8×8 = 36+64 = 100 square root of 100 is 

10. 

Fill in the blanks with appropriate java statements. 

void norm ( int n) 

 { 

int d, s =(a)______; 

 while ( (b)_________) 

d = n%10; 

s = (c)________________; 

n=n/10; 

 } 

System.out.println(“Norm = “ + (d)_____________); 

Choose the correct option 

(a) 

Options -

1. 0 

2. 0.0 

3. 1 

 (b) 

options

1. n>0 

2. n<0 

3. n>1 

(c) 

options

1. s+d*d 

2. s*d+d 

3. s*s+d 

(d) 

options

1. Math.sqrt(s) 

2. Math.SQRT(s) 

3. Math.sqrt(n)

Answered by Jasleen0599
3

JAVA PROGRAM

void norm (int n)

{

int d,

s=0

while (n>0)

d = n % 10,

s=s+d*d

n=n/10,

System.out.println("Norm=+ (Math.sqrt(s)));

}

  • The square root of the sum of all the squares of an integer is the norm of that number. For instance, the norm of 68 is 10. 6 x 6 + 8 x 8 = 36 + 64 = 100 V100= 10.
  • Java.lang is used. The positively rounded square root of a double value is returned by the math function math.sqrt(double a). Special circumstances The result is NaN if the argument is NaN or less than zero. Positive infinity is the result if the argument is positive infinity.
  • There are two methods in Java for squaring numbers. One method is to multiply the amount by itself. The second method involves utilising the Math. pow() function, which requires two parameters: the number that needs to be changed and the increase in power that you want to make.

#SPJ3

Similar questions