Search C Program

Loading...

Number Pattern - 29

1        1
12      21
123    321
1234  4321
1234554321

#include<stdio.h>

int main()
{
  int i,j,k;
  for(i=1;i<=5;i++)
  {
    for(j=1;j<=5;j++)
    {
      if(j<=i)
        printf("%d",j);
      else
        printf(" ");
    }
    for(j=5;j>=1;j--)
    {
      if(j<=i)
        printf("%d",j);
      else
        printf(" ");
    } 
    printf("\n");
  }
  return 0;
}


Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C


2 comments:

  1. import java.util.Scanner;
    public class P2 {

    public static void main (String[] args)
    {
    Scanner sc=new Scanner(System.in);
    System.out.println ("enter the length(max 9)");
    int n=sc.nextInt();
    int m=2*n;
    for(int i=0;i=(m-(i+1)))
    {
    System.out.print(m-j);


    }
    else
    System.out.print(" ");
    }
    System.out.println ("");

    }

    }


    }

    ReplyDelete
  2. public class next {
    public static void main(String[] args){
    int l=1;
    for(int i=1;i<=5;i++){

    for(int j=1;j<=10;j++){

    if(j<=i)
    System.out.print(l++);


    else if((10-j)<i)
    {
    l-=1;
    System.out.print(l);

    }
    else
    System.out.print(" ");

    }
    System.out.println();
    l=1;
    }
    }
    }


    ReplyDelete