-->

program to display following star pattern.

/*program to display following star pattern.
              *
             *     *                                                                                                  
             *            *
             *                   *
             * * * * * * * * *                
             * *
             *     *
             *         *
             *             *
             *                  *
             *  * * * * * * * *
             *
             *
             *
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,k,m,sp=7;
//printf("first upper part");
for(i=1;i<=5;i++)
 {

for(m=i;m<= i;m++)
{
printf("*");
}
 for(m=1;m<i;m++)
 {
 printf("  ");
 }
   for(m=i;m<=i;m++)
    {
      if(m==1)
      printf(" ");
      else
      printf("*");

    }

 printf("\n");
 }
 for(i=1;i<=10;i++)
 {
 printf("*");
 }
//printf("second lower part");
for(i=1;i<=5;i++)
 {

for(m=i;m<= i;m++)
{
printf("*");
}
 for(m=1;m<i;m++)
 {
 printf("  ");
 }
   for(m=i;m<=i;m++)
    {
      if(m==1)
      printf(" ");
      else
      printf("*");

    }

 printf("\n");
 }
 for(i=1;i<=10;i++)
 {
 printf("*");
 }
  for(i=1;i<=5;i++)
 {
 printf("*\n");
 }
 getch();
 }
-------------------------------
logics in mind:-
-------------------------------
1)it contains three parts:
        first part is upper right angled triangle
        second part is lower right angled triangle
        third part is tail
If we combine them then we get that.
2) To get upper part we have already done. follow the link
            https://practicingclanguage.blogspot.com/2016/09/program-to-display-following-star_21.html
3)To get lower part, follow the link
        https://practicingclanguage.blogspot.com/2016/09/program-to-display-following-star_21.html
4) to get left part, use loop few number of times. It's done
---------------------------------------------------------------------------------
Follow following shot for more.

program screenshot:-

output screen shot:-




program to display following star pattern/triangle

//program to display following star pattern/triangle
//program to display following star pattern
//              *
//           *     *                                                                                                    
//        *            *
//     *                   *
//  *                          *

//* * * * * * * * * * * * * *
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,k,m,sp=7;
for(i=1;i<=5;i++)
 {
     for(k=sp;k>=i;k--)
     {
       printf(" ");
     }
for(m=i;m<= i;m++)
{
printf("*");
}
 for(m=1;m<i;m++)
 {
 printf("  ");
 }
   for(m=i;m<=i;m++)
    {
      if(m==1)
      printf(" ");
      else
      printf("*");

    }
printf("\n");
}

 for(int i1=1;i1<=5;i1++)
 {

   printf(" * ");
 }

 getch();
 }
------------------------------
logic in mind
----------------------
1.)The given pattern has two parts.
          *
       *
  *
*
second 
             *
                *
                   *
                        *

and third is
 * * * * *  * * *
so for these three, we use three loops with spaces between them when we combine them.
1)since there are five asterisks we display using loop with decreasing spaces(see figure).First loop is used for number of rows used.Second loop is for space(decreasing)

2)third loop is displaying star.
3)the loop inside is for space and for right pattern display.then we display second part with increasing space between them. After that we display second part with next loop as shown below(picture).
4) In second part we use 'if' because we have to display first space rather asterisk so.

5)Now, left is last row.For this, we have used another loop as shown in picture given downside. 
---------------------------------------------------------------------------------------
more about this logic , you can understand from following screenshot.

-----------------------------------------------------------------------------------------------
program screenshot:-

output screenshot:-

program to display following star pattern.

//program to display following star pattern.
//  *
//  *     *                                                                                                     
//  *            *
//  *                   *
//  * * * * * * * * **  
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,k,m;
for(i=1;i<=5;i++)
 {

for(m=i;m<= i;m++)
{
printf("*");
}
 for(m=1;m<i;m++)
 {
 printf("  ");
 }
   for(m=i;m<=i;m++)
    {
      if(m==1)
      printf(" ");
      else
      printf("*");

    }

 printf("\n");
 }
 for(i=1;i<=10;i++)
 {
 printf("*");
 }
 getch();
 }
----------------------------------
logic in mind
-----------------------------------
1.)The given pattern has three parts.
          *
          *
          *
          *
          *
second part:

             *
                  *
                      *
                          *
third part:
            ****************
If we combine them then we get given pattern.1)so for these three, we use three loops
2)since there are five asterisks we display using loop without space(see figure).
3)then we display second part with increasing space between them. For space, we have used loop.
           This part contains 'if' because we have to decide display first space rather asterisk so.
4) In third part, we use loop to display horizontally.
     For more, look downside.
---------------------------------------------------------------------------------------
   program's screenshot: 

output's screenshot:-

program to display following star pattern

//program to display following star pattern
//              *
//           *     *                                                                                                    
//        *            *
//     *                   *
//  *                          *
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,k,m,sp=7;
for(i=1;i<=5;i++)
 {
 for(k=sp;k>=i;k--)
      {
      printf(" ");
      }
for(m=i;m<= i;m++)
{
printf("*");
}
 for(m=1;m<i;m++)
 {
 printf("  ");
 }
   for(m=i;m<=i;m++)
    {
      if(m==1)
      printf(" ");
      else
      printf("*");

    }

 printf("\n");
 }
 getch();

 }
------------------------------
logic in mind
----------------------
1.)The given pattern has two parts.
          *
       *
  *
*
and 
             *
                *
                   *
                        *
so for these two, we use two loops with spaces between them when we combine them.
2)since there are five asterisks we display using loop with decreasing spaces(see figure).
3)then we display second part with increasing space between them. After that we display second part with next loop as shown below(picture).
4) In second part we use 'if' because we have to display first space rather asterisk so.
---------------------------------------------------------------------------------------
more about this logic , you can understand from following screen shot.

output screenshot is:-

program to display given numeric pattern

//program to display following numeric pattern.
//               1 2 3 4 5
//               6 7 8 9 10
//               11 12 13 14 15
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int i,j,k=0;
 for(i=1;i<=3;i++)
   {
   for(j=1;j<=5;j++)
       {
       printf(" %d",j+k);
      }
    printf("\n");
k=k+5;}
getch();
}
-----------------------------------
logic in mind:-
------------------------------------
1)we have to display 1 2 3 4 5 then different numbers in second row..
2)we can see there are three rows so we use first loop(outer) with three execution times. And there are         5 columns so we use one another loop(five times execution) for columns(inner).
3) since the pattern is like
        1+0   2+0   3+0  4+0  5+0
       1+5   2+5   3+5   4+5  5+5
and so on.
4) For this, We have used nested loop as shown above and one variable named k with initial value '0'.
5)For each value of outer loop(value of 'i'), the inner loop executes 5 times. And it goes to display numbers.
 while displaying, it adds both numbers (j and k)and displays on screen.
6)In second display the value of k is increased by 5 as shown above.
-------------------------------------------------------------------------------------------------------
program's screenshot
---------------------------


---------------------------
output is:-
----------------

program to display following numeric pattern.

//program to display following numeric pattern.
//               1 2 3 4 5
//               2 4 6 8 10
//               3 6 9 12 15
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int i,j;
 for(i=1;i<=3;i++)
   {

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

      {
      printf(" %d",i*j);

     }

    printf("\n");

}

getch();

}
-----------------------------------
logic in mind:-
------------------------------------
1)we have to display 1 2 3 4 5 then different numbers in second row..
2)we can see there are three rows so we use first loop(outer) with three execution times. And there are    5 columns so we use one another loop for columns(inner).
3) since the pattern is like
        1*1  1*2 1*3 1*4 1*5
       2*1   2*2 2*3 2*4 2*5
and so on.
4) For this, We have used nested loop as shown above.
5)For each value of outer loop(value of 'i'), the inner loop executes 5 times. And it goes to display numbers.
 while displaying, it multiplies both numbers and displays on screen.

  ------------------
program's screenshot with output:-
----------------------------------------------------
program's screen
output's screen


program to display following numeric pattern

program to display following numeric pattern.
//                   1 
//                 2 2
//               3 3 3
//              4 4 4 4
//            5 5 5 5  5     
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,sp=15;
 for(i=1;i<=5;i++)
   {
               for(k=sp;k>=i;k--)
                 {
                  printf(" ");
                  }
                        for(j=1;j<=i;j++)
                           {
                            printf(" %d",i);
                          }
           printf("\n");
  }
getch();
}
-----------------------------
logic in mind:-
------
1)we have to display 1,2 2,3 3 3 and so on. We use loop for this.
 2)since the displays are in repetitive form ,,we set up the loop in nested form such that
        internal loop executes from 1 to 5 times with display of numbers(above).Because numbers are from 1 then        2 then 3....To display number, we take variable 'i' from outer loop.It's repeated by inner loop.
3)if we look carefully to given pattern, we can see there space decreased after each display. for this, we have used loop. in each display, it decreases space and then it goes for next display.
3)First loop(outer) takes value 5 and assigns to inner.The inner executes 5 times with display.
4)next time, the outer loop takes the value 1 and transfers to inner loop, it displays again and again.
and it goes on
-----------
note:
--------------
if you want to display "*" (star) then use "*" in printf function. ------------------------