Saturday, 27 October 2018

square root of number in java Example | sqrt() function in java

/* java program to find square root of a Number */
class MathDemo{
public static void main(String args[]){

// values for square root
double a = 144;
double b = 9;

//result of square root
System.out.println("\nSquare root of 144 is : "+Math.sqrt(a));
System.out.println("\n Squre root of 9 is : "+Math.sqrt(b));

}
}

o/p
Square root of 144 is :12
Square root of 9 is : 3

Friday, 26 October 2018

How to Convert Double To String in JAVA Example

/* JAVA Program of  Convert Double To String (Java Converion )*/

class ConversionDemo{
public static void main(String args[]){
        //method 1 using valueOf Method

double value = 222.02;
String str = String.valueOf(value); // converion
System.out.println("using valueOf Method :"+str);

// method 2 using toString method
double dval = 303.04

String str2 = Double.toString(dval); //converion
System.out.println("Conversion Using toString Method :"+str2);


}
}

Sunday, 21 October 2018

isalnum() function in C programming - ctype.h library function

/* write a C program to check Enter character is Alphanumeric or Not */

#include<stdio.h>
#include<conio.h>
#include<ctype.h> // library for islower function must require it
void main()
{
       char c;
       printf("Enter character : ");
       scanf("%c",&c);
     
       if(isalnum(c)==0)
           printf("Enter character is Not  alphanumeric character");
       else
          printf("Enter character is alphanumeric  character");
getch();

}

isupper() function in ctype.h Library in C programming

#include<stdio.h>
#include<conio.h>
#include<ctype.h> // library for islower function must require it
void main()
{
       char c;
       printf("Enter character : ");
       scanf("%c",&c);
     
       if(isupper(c)==0)
           printf("Enter character is Not a upper case character");
       else
          printf("Enter character is upper case character");
getch();

}

islower() function in c - ctype.h library function

#include<stdio.h>
#include<conio.h>
#include<ctype.h> // library for islower function must require it
void main()
{
       char c;
       printf("Enter character : ");
       scanf("%c",&c);
     
       if(islower(c)==0)
           printf("Enter character is Not a lower case");
       else
          printf("Enter character is Lower case");
getch();

}

JTable Hide and Show in Java Swing