-->

program to display given star/number pattern

//program to display given star/number pattern
//      1 1 1 1 1
//         2 2 2
//            3
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,sp=5,m=1;
 for(i=5;i>=1;i=i-2)
   {
               for(k=sp;k>=i;k--)
                 {
                  printf(" ");
                  }
                        for(j=1;j<=i;j++)
                           {
                            printf(" %d ",m);
                          }
           printf("\n");
     m++;
  }
getch();
}
---------------------------------
logics in mind
-------------------------------
1)we have to display 1 1 1 1 1 so we use loop.
 2)since the displays are in repetitive form ,,we set up the loop in nested form such that
        internal loop executes 5 times with display of numbers(above),then 3 times and then 1 time.
3)if we look carefully to given pattern, we can see there space increased after each display. for this, we have used loop. in each display, it increases 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 3 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.   

program to display following numeric/star pattern.

//program to display following numeric/star pattern.          
 // 1 1 1 1 1
 // 2 2 2 2 2
//  3 3 3 3 3
//  4 4 4 4 4
#include <stdio.h>
#include<conio.h>
void main() { int i,j; for(i=1;i<=4;i++) { for(j=1;j<=5;j++) { printf(" %d ",i); } printf("\n"); } getch(); }
-----------------------------


Logic in mind:
----------------------

1)we have to display 1 1 1 1 1,then 2 2 2 2 2 2 ,and so on.  we use loop for this.
      We have to know one thing here that, there are four rows and five columns. so for this, we use nested loop. The outer loop is for rows and inner loop is for columns.
 2)accordingly we set up the loops.since the displays are in repetitive form ,,we set up the loop in nested form such that
        internal loop executes first  time with display of numbers(above) taken from outer loop and that is '1' first and '2' ..., 
five  times
.3)First loop(outer) takes value 1 and assigns to display unit(printf).The inner executes five times with display taken from outer loop.
4)next time, the outer loop takes the value 2 and transfers to  display unit. the inner loop displays the number again and again(five times)and it goes on.
............................................................................................
if you want to display "*" then use "*" in printf function.                                                            

program to display following numeric/star pattern.

//program to display following numeric pattern.
//      5
//      44
//      333
//      2222
//      11111        
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=5;>=1;i--)
  {
     for(j=5;j>=i;j--)
          {
                printf("%d",i);
          }
       printf("\n");
 }
getch();
}
--------------------------------------------------------
logics in mind:
----------------------
1)we have to display 5,then 44, then 333,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 first  time with display of numbers(above) which it takes from outer loop,then 
two times  and it goes on decreasing.
3)First loop(outer) takes value 5 and assigns to inner.The inner executes one time with display taken from outer loop.
4)next time, the outer loop takes the value 4 and transfers to inner loop, it displays number taken from outer loop again and again.and it goes on.
............................................................................................
if you want to display "*" then use "*" in printf function.                                                            

program to display following numeric/star pattern.

//program to display following numeric/star pattern.
//     11111
//     2222
//     333
//     44
//     5            
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=1;<=5;i++)
  {
     for(j=5;j>=i;j--)
          {
                printf("%d",i);
          }
       printf("\n");
 }
getch();
}
--------------------------------------------------------
logics in mind:
----------------------
1)we have to display 1,then 2222, then 333,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 first  time with display of numbers(above) which it takes from outer loop,then 
four times  and it goes on decreasing.
3)First loop(outer) takes value 1 and assigns to inner.The inner executes five times with display taken from outer loop.
4)next time, the outer loop takes the value 2 and transfers to inner loop, it displays number taken from outer loop again and again.and it goes on.
............................................................................................
if you want to display "*" then use "*" in printf function.

program to display following numeric/star pattern.

//program to display following numeric pattern.
//      1
//      12
//      123
//      1234
//      12345 
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=1;i<=5;i++)
  {
     for(j=1;j<=i;j++)
          {
                printf("%d",j);
          }
       printf("\n");
 }
getch();
}
--------------------------------------------------------
logics in mind:
----------------------
1)we have to display 1,then 12, then 1233,so on.  we use loop fo this.
 2)since the displays are in repetitive form ,,we set up the loop in nested form such that
        internal loop executes first one  time with display of numbers(above),then two times  and it goes on increasing.
3)First loop(outer) takes value 1 and assigns to inner.The inner executes one times with display.
4)next time, the outer loop takes the value 2 and transfers to inner loop, it displays again and again.
and it goes on
............................................................................................
if you want to display "*" then use "*" in printf function.

program to display star/number pattern

//program to display given star/number pattern
//      12345
//        1234
//          123
//            12
//              1
#include<stdio.h>
#include<stdio.h>
void main()
{
clrscr();
int i,j,k,sp=5;
 for(i=5;i>=1;i--)
   {
               for(k=sp;k>=i;k--)
                 {
                  printf(" ");
                  }
                        for(j=1;j<=i;j++)
                           {
                            printf("%d",j);
                          }
           printf("\n");
  }
getch();
}
---------------------------------
logics in mind
-------------------------------
1)we have to display 1,2,3,4,5 so we use loop.
 2)since the displays are in repetitive form ,,we set up the loop in nested form such that
        internal loop executes 5 times with display of numbers(above).
3)if we look carefully to given pattern we can see there space increased after each display. for this, we have used loop. in each display, it increases 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 4 and transfers to inner loop, it displays again and again.
and it goes on

...................................................
if you wan to display star then put "*" in printf


program to display following numeric pattern.

//program to display following numeric pattern.
//      12345
//      1234
//      123
//      12
//      1
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
for(i=5;i>=1;i--)
  {
     for(j=1;j<=i;j++)
          {
                printf("%d",j);
          }
       printf("\n");
 }
getch();
}
--------------------------------------------------------
logics in mind:
----------------------
1)we have to display 1,2,3,4,5 so we use loop.
 2)since the displays are in repetitive form ,,we set up the loop in nested form such that
        internal loop executes 5 times with display of numbers(above).
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 4 and transfers to inner loop, it displays again and again.
and it goes on