Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

Continuous Number Pattern C Program

Q. Write a C program to make the following continuous number pattern as:

     1
     2 6
     3 7 10
     4 8 11 13
     5 9 12 14 15

Ans.

Before write to start the C coding, first of all you should the understand the concept of above number pattern.

Source design of number pattern C program
Figure: Source design of number pattern C program
Now it is easy to make the program, now you know that where from to start and how the program execute or run.
let's start the writing the source code of above continuous number pattern C program:

/* continuous number pattern C program source code*/
#include<stdio.h>
int main()
{
 int num,n,r,c,p;
 printf("Enter Total No. of Row : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
   for(c=1, p=r, n=num; c<=r; c++, n--, p=p+n)
       printf(" %d ", p);
  printf("\n");
 }
 getch();
 return 0;
}

/*************************************************************
The output of above number pattern C program would be:
************************************************************/
output of continuous number pattern in C program
Figure: Screen shot of continuous number pattern in C program output

You might also like to read:

  1. Big list of 98+ C pyramid programs
  2. Latest user asking pyramid programs list




0 komentar:

Post a Comment

Continuous Number Pattern C Program