Posted by: Sourav | April 12, 2015

decreasing and increasing star pattern example using only i and j and only 2 loop in C


#include<stdio.h>

void main()
{
int i,j;
for(i=4;i>=-4;i–)
{

for(j=(abs(i)+1);j>=1;j–)
{

printf(“*”);
}

printf(“\n”);
//printf(“%d”,i);

}
}

this will produce a pattern like this

****

***

**

*

**

***

****

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: