Search C Program

Loading...

Number Pattern - 19

1
23
456
78910

#include<stdio.h>
int main()
{
  int i,j,k;
  k=1;
  for(i=1;i<5;i++)
  {
    for(j=1;j<=i;j++)
    {
      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



8 comments:

  1. program to print the above pattern up to a given value n & the program should use a function which takes n as its parameter..........

    pls help me....

    ReplyDelete
    Replies
    1. #include
      int main()
      {
      int i,j,k,n;
      printf("Enter value of n:")
      scanf("%d",&n);
      k=1;
      for(i=1;i<n;i++)
      {
      for(j=1;j<=i;j++)
      {
      printf("%d",k++);
      }
      printf("\n");
      }
      return 0;
      }

      Delete
  2. insert printf and scanf to scan the value of n
    then instead of i<5, put i<n

    ReplyDelete
  3. the program has prototype error.

    ReplyDelete
  4. sir pls do this program using only two variable i and j not any other variable

    ReplyDelete
  5. ankita anand ,
    because u cannot predict the value naturally that where its ending in each row that is
    weather 3 6 pr 10
    in the ist line its printing from 1 to 1 as the value of i is equal to 1
    similarly
    in the second line its printing the from the incremented value of i ie
    from 2 to 3 as i = 2 here so two time u are printing two numbers two and 3 as k is also incrementing simultaneously
    got it?

    ReplyDelete
  6. #include

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

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

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

    ReplyDelete