10.11.2015

3 Nested Number Pattern C Program

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

     10 9 8 7 6 5 4 3 2 1 0
     10 9 8 7 5 3 2 1 0
     10 9 8 5 2 1 0
     10 9 5 1 0
     10 5 0
     5    

Ans.

Before you start to write down the source code of above number pattern program, carefully look the number pattern and divide it sub pattern as following:

     10 9 8 7 6 5 4 3 2 1 0
     10 9 8 7 5 3 2 1 0
     10 9 8 5 2 1 0
     10 9 5 1 0
     10 5 0
     5 


Now it is easy to understandable, there are 3 types number pattern triangle program. 

So first of all write the code for first number pattern program, after that make second number pattern program and lastly write the code 3rd number pattern program.
Now merge them. You are done. Cheers !!

Let's start the coding of above C program.

/*c program for number pattern program*/
#include<stdio.h>
int main()
{
  int num=6,r,c,n,p;
  n=num;
  for(r=1; r<=num; r++,n++)
  {
    for(c=10; c>=n; c--)
        printf(" %d", c);
    printf(" 5");
    for(c=num-r-1; c>=0; c--)
        printf(" %d", c);
    printf("\n");
  }
  getch();
  return 0;
}


/***********************************************************
The output of above number pattern program would be:
*************************************************************/


Output of 3 Nested Number Pattern C Program
Figure: Screen shot of 3 Nested Number Pattern C Program 

You might also like to read:

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

2 comments:

  1. Hi
    Please give me a program of different area?
    I need explication about how to programm a different area too.
    Thank you

    ReplyDelete
  2. Help me with surface programming please

    ReplyDelete