English

Write a program for the following. Input a string to display these patterns. Assume the string is "CALENDAR" Calendar Alendar Lendar Endar Ndar Dar Ar R

Advertisements
Advertisements

Question

Write a program for the following.

Input a string to display these patterns. Assume the string is "CALENDAR"

Calendar

Alendar

Lendar

Endar

Ndar

Dar

Ar

R

Code Writing
Advertisements

Solution

importjava.util.*;
class clTask
{
     void main()
     {
         String s1 ="";
         Scanner sc = new Scanner(System.in);
         System.out.print(" Enter a sentence : ");
         s1 = sc.nextLine();
         int len = s1.length();
         for(int j = 0; j <= len − 1; j++)
         {
             System.out.println(s1.substring(j));
         }
     }
}

Output:

OUTPUT: Enter a string : CALENDAR

CALENDAR

ALENDAR

LENDAR

ENDAR

NDAR

DAR

AR

R

shaalaa.com
  Is there an error in this question or solution?
Chapter 10: String Handling - Exercises [Page 249]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 10 String Handling
Exercises | Q 3. (i) (i) | Page 249
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×