Advertisements
Advertisements
प्रश्न
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
उत्तर
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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 10: String Handling - Exercises [पृष्ठ २४९]
