Wednesday, December 31, 2014

WAP to display the pattern of string "INDIA".

/*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