The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

C Number Pattern - 12

Why Number Pattern

In most of the MNC interview questions such as in Zoho interview questions, IVTL Infoview interview questions, Amazon interview questions, Google interview questions, Infosys interview questions and even in Voonik interview questions, we come across number pattern questions with a probability of 1:5. We provide you a most commonly asked number pattern question for your interview preparation using C programming.

Lets code a C program to print following number pattern to have some fun

Number Pattern Logic in C Programming

C Program - Number Pattern

We challenge you, the programmer to do the following number pattern using C programming

c-number-pattern.c
#include <stdio.h>
int main()
{
int a, i, j;
for(a = 5;a >= 1;a--)
{
for(i = a;i <= 5;i++)
{
printf("%d", i);
}
for(j = a-1;j >= 1;j--)
{
printf("5");
}
printf("\n");
}
return 0;
}
55555
45555
34555
23455
12345

Note:

Here we make use of three for loops. First for loop is to say the number of lines to be printed . Second for loop is to print numbers from 1 to 5. Third for loop is to print 5.

Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.

Report