Advertisements
Advertisements
प्रश्न
Define a class to overload the method display as follows:
| void display(): |
To print the following format using nested |
| void display(int n): | To print the square root of each digit of the given number |
| Example: |
n = 4329 |
कोड लेखन
Advertisements
उत्तर
class Overload_X
{
public void display()
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
public void display(int n)
{
while(n>0)
{
int r=n%10;
System.out.println(Math.sqrt(r));
n=n/10;
}
}
}shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
