OUTPUT:
CONCEPT:
To print Z first print horizontal lines of Z as per condition and the main problem is to print diagonal elements (means star) so for that, we can use if(i==j).
for better understanding refer below code
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=5;j>=1;j--)
{
if(i==j||i==1||i==5)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
getch();
}
0 Comments
if you have any doubt, plz let me know