Ad Code

NEW POST

6/recent/ticker-posts

HOW TO MAKE 'M' ALPHABET FROM STAR* PATTERN? VERY SIMPLE LOGIC!!

OUTPUT:



CONCEPT:

For making M first define i and j loop rows and coloumns then first print horizontal line form 'M' and print diagonals elements(if(i==j)) 

and in next line reverse it M patter will be ready..


below code will help to understand


 

C CODE(RUNS ON TRUBO C++):

#include<conio.h>

#include<stdio.h>

void main()

{

int i,j;

clrscr();

for(i=1;i<=8;i++)

{

for(j=8;j>=1;j--)

{

if(j==1||i==j)

{

printf("*");

}

else

{

printf(" ");

}

}

printf("\n");

for(j=1;j<=8;j++)

{

if(j==1||i==j)

{

printf("*");

}

else

{

printf(" ");

}

}


}

getch();

}

Post a Comment

0 Comments