हिंदी

Write a program to input a number. Calculate its square root and cube root. Finally, display the result by rounding it off. Sample Input: 5Square root of 5 = 2.2360679Rounded form = 2 - Computer Applications

Advertisements
Advertisements

प्रश्न

Write a program to input a number. Calculate its square root and cube root. Finally, display the result by rounding it off. 

Sample Input: 5
Square root of 5 = 2.2360679
Rounded form = 2
Cube root of 5 = 1.7099759
Rounded form = 2 

संक्षेप में उत्तर

उत्तर

import java.util.*;
public class Q3
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
long x, cb, sq;
System.out.printIn(“Enter a number”);
x = in.nextInt();
sq = Math.round(Math.sqrt(x));
cb = Math.round(Math.cbrt(x));
System.out.printin(“Square root = " + sq);
System.out.println(“Cube root = " + cb);
}}
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1.07: Mathematical Library Methods - EXERCISES [पृष्ठ ८१]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
अध्याय 1.07 Mathematical Library Methods
EXERCISES | Q VI. 3. | पृष्ठ ८१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×