-->

to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");

}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-










to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");
  //a++;
}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-










to display letters' pattern

/*to display following
A
AB
ABC
ABCD
ABCDE
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char a='A';
int i,j,k=0;
for(i=1;i<=5;i++)
{
  for(j=0;j<i;j++)
    {
      printf("%c",a+j);
    }
  printf("\n");

}
getch();
}
-------------------
logic in mind:-
-------------
1) we have to display different characters in different rows and columns.
2)there are five rows and columns. The column is decreased in each display.
3)for this, we have used first loop for different rows.
4)second loop is for display. It fetches value from first loop and displays different character.
5)second loop is taken from value 0.because,  in each display, the character changes so.
for more: look down.
program screenshot:-


program output:-










Write a program to get following numeric pattern.

/*Write a program to get following numeric pattern.
0
01
012
0123                                                                                                                    
012
01
0
*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for(i=0;i<=3;i++)
{
 for(j=0;j<=i;j++)
   {
      printf("%d",j);

   }
      printf("\n");
}
for(i=2;i>=0;i--)
{
 for(j=0;j<=i;j++)
   {
      printf("%d",j);

   }
      printf("\n");
}
getch();
}
-------------------------------------------------
logic in mind:-
1) we have to display given pattern.It has two parts
      first part is:upper part .i..e
        0
       01
       012
        0123   
  and second part is
     012
     01
     0
2)for first part, like shown below, we use loop to fetch value from outer loop and displaying from inner loop
3)for second part, we use once again loop with one less value. We fetch that and display from inner loop
just look down.

program's screenshot:

----------------------------
output screen:



program to display following star pattern.

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

     }
    for(j=5;j>=i;j-- )
      {
printf(" *");
    }
    printf("\n");
}
 //printf("for lower part");

 sp=5;
 for(i=1;i<=5;i++)
   {
for(k=sp;k>=i;k=k-1)
  {   printf(" ");

     }
    for(j=1;j<=i;j++)
      {
      printf(" *");
    }
    printf("\n");
}
getch();

}
-------------------------------
logic in mind:-
---------------------------------
1)First loop is for number of rows.
2)like other programs, we display first upper part. 
       For this, we, first, display space (second loop)and then star(third loop.
3)For second part, we display first space(look diagram) using loop then we display star.
------------------------------------------------------------------------------------------------------------------------------
program's screenshot:-


programs output:-



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:-