Computer Science, asked by coolnike, 1 year ago

write a program to print a pattern in string

I
N
D
I
A

Answers

Answered by syedshahid7777777
0
/*C program to display the string as given pattern*/
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
static char str[]="INDIA";
for(x=0; x<5; x++)
{
y=x+1;
printf("%-5.*s\n",y,str);
}
for(x=4; x>=0; x--)
{
y=x+1;
printf("%-5.*s\n",y,str);
}
getch();
}

Expected Output:

I
IN
IND
INDI
INDIA
INDIA
INDI
IND
IN
I
Answered by Anonymous
0

Public class pattern
{
Public static void main (String arg[])
{
Scanner in =new Scanner (System. In)
Int a, b
String st
System. Out. Println ("enter word to display pattern ")
St=in.next()

b=st.length()
System. Out. Println("pattern is")
For(a=0 .a<b,a++)
{
System. Out. Println(st.charAt(a))

}
}
}
Output :
Enter the word
BLUEJ
Pattern is:
B
L
U
E
J

Similar questions