OUTPUT:
CONCEPT:
Now we can easily print V.how to print V ? recall (first define loops for i and j respectively rows and column)
now use IF condition to print stars like this if(i==j) printf ("*"); and reverse it in the next line you will get V
now very simple task to print a vertical line define another loop or continue with j and put if condition and print the line.
below code will help you to understand better.
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");
}
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
printf(" ");
}
for(j=1;j<=1;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
0 Comments
if you have any doubt, plz let me know