write a program to display the given pattern
Answers
write a program to display the given pattern
Results in English
दिए गए पैटर्न प्रदर्शित करने के लिए एक प्रोग्राम लिखने
हिन्दी में नतीजे
Search Results
Featured snippet from the web
Pattern program in C
int main() { int row, c, n;
printf("Enter the number of rows in pyramid of stars to print\n"); scanf("%d", &n);
for (row = 1; row <= n; row++) // Loop to print rows. { ...
for (c = 1; c <= 2*row - 1; c++) // Loop to print stars in a row. printf("*");
printf("\n"); }
do same as like this
Write a program to display the given pattern
BLUEJ
BLUE
BLU
BL
B
Explanation:
Java program to print given pattern
public class Main
{
public static void main(String args[])
{
System.out.println(); // new line
String str="BLUEJ"; // store given word in string str
int k=0,n; //variable declaration
n=str.length(); // store string length in variable n
for(int i=n;i>=0;i--) // loop to display given pattern
{
for(int j=0;j<k;j++)
{
System.out.print(" ");
}
System.out.println(str.substring(0,i));
k++;
}
}
Output of above program
BLUEJ
BLUE
BLU
BL
B