OUTPUT:
CONCEPT:
For printing V we will use a very easy trick use if(i==f) and in the next line reverse it in the same loop.
if you don't know how to reverse the loop kindly check our blog for reversing the loop.
below code for W.
C CODE(RUNS ON TURBO C++)
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==j)
{
printf("*");
}
else
{
printf(" ");
}
}
//printf("\n");
for(j=5;j>=1;j--)
{
if(i==j)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
getch();
}
0 Comments
if you have any doubt, plz let me know