Ad Code

NEW POST

6/recent/ticker-posts

HOW TO MAKE ALPHABET 'Q' FROM STARS * PATTERN ?

OUTPUT:


CONCEPT:

First print 0.use very simple logic to print 0 and then define another loop for diagonal printing stars


you will understand below code better:


c code(runs on turbo c++):

 #include<stdio.h>

#include<conio.h>

void main()

{

int i,j;

clrscr();

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

{

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

{

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

{

printf("*");

}

else

{

printf(" ");

}

}

printf("\n");

}


for(i=9;i<=15;i++)

{

for(int k=9;k<20;k++)

{

if(i==k)

{

printf("         *");    //9TIMES SPACE

}

else

{

printf(" ");

}

}

printf("\n");

}

getch();

}

Post a Comment

0 Comments