program to print the ascii value according to alphabets. || Type casting in java Language.
class alphabet {
public static void main(String[] args) {
char ch='a';
while(ch<='z') {
System.out.println("the ascii value of "+ch +" is ="+(int)ch); // (int) char => type casting
ch++;
}
}
}
■》 output->
the ascii value of a is =97
the ascii value of b is =98
the ascii value of c is =99
the ascii value of d is =100
the ascii value of e is =101
the ascii value of f is =102
the ascii value of g is =103
the ascii value of h is =104
the ascii value of i is =105
the ascii value of j is =106
the ascii value of k is =107
the ascii value of l is =108
the ascii value of m is =109
the ascii value of n is =110
the ascii value of o is =111
the ascii value of p is =112
the ascii value of q is =113
the ascii value of r is =114
the ascii value of s is =115
the ascii value of t is =116
the ascii value of u is =117
the ascii value of v is =118
the ascii value of w is =119
the ascii value of x is =120
the ascii value of y is =121
the ascii value of z is =122
Comments
Post a Comment