मराठी

Write a program in Java to display the following pattern: AabABCabcdABCDE - Computer Applications

Advertisements
Advertisements

प्रश्न

Write a program in Java to display the following pattern:

A
ab
ABC
abcd
ABCDE 

थोडक्यात उत्तर

उत्तर

public class Q12a{
public static void main(String args[])
{
String s = "abcde"; 
System.out.println("\n\n");

for (int i = 0; i <= 4; i++) 
{ for (int j = 0; j <= i; j++) 
{ if (i % 2 = 0)
System.out.print(Character.toUpperCase(s.charAtG))); 
else
System.out.print(Character.toLowerCase(s.charAtU))); 
}
System. out. println();
}
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 2: Library Classes - EXERCISES [पृष्ठ १८०]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
पाठ 2 Library Classes
EXERCISES | Q VIII. 12. (a) | पृष्ठ १८०
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×