Q. Write a program to display the string INDIA in the following fashion:
I
IN
IND
INDI
INDIA
INDIA
INDI
IND
IN
I
Ans.
/*program to display the string as given fashion*/
#include<stdio.h>
#include<conio.h>
int 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();
return 0;
getch();
return 0;
}
Output:-
I
IN
IND
INDI
INDIA
INDIA
INDI
IND
IN
I
- Write above program using macro
- Write above program using function
- Big 98+ C pyramids programs list
- Latest asking pyramid programs list
thanx so much...:)
ReplyDeleteits oosome.............:D
fantastic ...........
ReplyDeleteprintf("%-5.*s\n",y,str);
ReplyDelete