Write a Java program to assign a string and print it in the following way(ANSWER TRUTHFULLY AND LOGICALLY AND SPAMS WILL BE REPORTED)
COMPUTER
COMPUTE
COMPUT
COMPU
COMP
COM
CO
C
Share
Write a Java program to assign a string and print it in the following way(ANSWER TRUTHFULLY AND LOGICALLY AND SPAMS WILL BE REPORTED)
COMPUTER
COMPUTE
COMPUT
COMPU
COMP
COM
CO
C
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
public class Program
{
public static void main(String[] args) {
// assign the value of string COMPUTER:
String str="COMPUTER";
// printing the pattern using for loop:
for(int i=0;i<str.length();i++){
for(int j=0;j<(str.length()-i);j++)
{
System.out.print(str.charAt(j));
}
System.out.println();
}
}
}
hope it help's you :D