Search C Program

Number Pattern - 24

    1
  2 3 4
5 6 7 8 9

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


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


10 comments:

  1. #include
    int main()
    {
    int i, j, n=1;
    for(i=1; i<=5; i+=2)
    {
    for(j=5; j>=i; j-=2)
    {
    printf(" ");
    }
    for(j=1; j<=i; ++j)
    {
    printf("%2d", n++);
    }
    printf("\n");
    }
    return 0;
    }

    ReplyDelete
  2. #include
    using namespace std;


    int main()
    {
    int n,k;
    cout<<"enter order:"<>n;
    for(int i=n;i>=1;i--){
    k=i-1;
    while(k){
    cout<<" ";
    k--;
    }
    for(int j=n;j>=i;j--){
    cout<<"*"<<" ";
    }


    cout<<endl;
    }
    return 0;
    }

    ReplyDelete
  3. function pattern7(){
    var some=value-1;
    var start=1;
    var one=1;
    //
    for(var i=1;i <= value;i++){

    for(var k=1;k <= some;k++){
    document.write('&nbsp&nbsp');
    }
    some--;
    //new_one++;

    for(var j=1;j <= (2*i)-1;j++){
    document.write('&nbsp');
    document.write(one);

    one=one+1;
    }

    //start=j;
    document.write('
    ');
    }
    }

    ReplyDelete
  4. #include
    #include
    void main()
    {
    int i,j,k=1;
    for(i=4;i>=0;i-=2
    {
    for(j=0;j<=4;j++)
    {
    if(j<i)
    {
    printf(" ");
    }
    else
    {
    printf("%d ",k);
    k++;
    }
    }
    printf("\n");
    }
    getch();
    }

    ReplyDelete
  5. any one help me how to do with i and j value only

    ReplyDelete
    Replies
    1. Those who posted their codes will have done it with only two variable, i and j. That's the goal. To use less variable as possible and make sure the program works for any kind of number.

      Delete
  6. int main()
    {
    int i, j, k;
    int m = 1;
    for (i = 1; i <= 3; i++)
    {
    for (j = i; j < 3; j++)
    {
    printf(" ");
    printf(" ");
    }
    for (k = 1; k < (i * 2); k++)
    {
    printf("%d",m);
    printf(" ");
    m += 1;
    }
    printf("\n");
    }
    return 0;
    }

    ReplyDelete
  7. #include

    int main()
    {
    int r,i,j,k,s;

    printf("Enter the no. of rows : ");
    scanf("%d",&r);

    for(i=1,k=1;i<=r;i++)
    {
    for(s=1;s<=r-i;s++)
    {
    printf(" ");
    }

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

    ReplyDelete
  8. #include
    #include
    #include

    int main(){
    int i,j,k;
    for(i=1;i<=3;i++){
    for(k=3-i;k>=1;k--){
    printf(" ");
    }
    for(j=(i*i-2*i+2);j<=i*i;j++){
    printf("%d ",j);
    }
    printf("\n");
    }
    }

    ReplyDelete