Upload
hitesh-sp
View
218
Download
0
Embed Size (px)
Citation preview
7/24/2019 Number Pattern Challenges
1/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html
10 Challenging number pattern programs in Cby U T S A V B A N E R J E E on N O V E M B E R 8 , 2 0 09
39 Votes
This is a continuation to the series of challenging pattern C
programsin Interview Mantra. This set of 10 puzzling programs
are of type number patterns.
Also read Print Pattern Programs
1. Write a C program to print the following pattern:
1
0 1
1 0 1
0 1 0 1
1 01 0 1
2. Write a C program to print the following pattern:
0
1 1
2 3 5
8 13 21
3. Write a C program to print the following pattern:
1
121
12321
1234321
12321
121
1
4. Write a C program to print the following pattern:
2
4 5 6
6 7 8 9 10
4 5 6
2
5. Write a C program to print the following pattern:
1 1
3 3 3 3 3 3
5 5 5 5 5 5 5 5 5 5
7 7 7 7 7 7 7 7 7 7 7 7 7 7
5 5 5 5 5 5 5 5 5 5
3 3 3 3 3 3
1 1
6. Write a C program to print the following pattern:
0-2-3 0
-4-3-2-1 0
-2-3 0
0
7. Write a C program to print the following pattern:
77777777777
7
7
7
7
7
7
7
7
7
http://www.interviewmantra.net/2009/2009/04/print-number-pattern-c-programs.htmlhttp://www.interviewmantra.net/2009/2009/04/print-number-pattern-c-programs.htmlhttp://www.interviewmantra.net/2009/2009/04/print-number-pattern-c-programs.htmlhttp://www.interviewmantra.net/author/utsav-banerjee7/24/2019 Number Pattern Challenges
2/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 2
7
8. Write a C program to print the following pattern:
1 1
1 0 1 0
1 0 1 1 0 1
1 0 1 0 1 0 1 0
1 0 1 0 1 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 1 0 1 0 1
1 0 1 0 1 0 1 0
1 0 1 1 0 1
1 0 1 0
1 1
9. Write a C program to print the following pattern:
1
2 4
3 6 9
2 4
1
10. Write a C program to print the following pattern:
1
1 0
1 0 01 0 0 0
1 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0
1 0 0 0
1 0 0
1 0
1
1. Write a C program to print the following pattern:
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
Program:
#include
int main(void) {
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j
7/24/2019 Number Pattern Challenges
3/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 3
0
1 1
2 3 5
8 13 21
Program:
#include
int main(void) {
int i, j, a = 0, b = 1, temp = 1;
for (i = 1; i
7/24/2019 Number Pattern Challenges
4/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 4
Download Code
Back to top
End of Question3 Start of Question4
4. Write a C program to print the following pattern:
2
4 5 6
6 7 8 9 10
4 5 6
2
Program:
#include
int main(void) {
int prnt;
int i, j, k, r, s, sp, nos = 3, nosp = 2; //nos n nosp controls the spacing fact
// Prints the upper triangle
for (i = 1; i = 1; s--) {
printf(" ");
}
for (j = 1; j = 1; k--) {
if ((k % 2) != 0) {
for (sp = nosp; sp >= 1; sp--) {
printf(" ");
}
for (r = 1; r
7/24/2019 Number Pattern Challenges
5/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 5
3 3 3 3 3 3
1 1
Program:
#include
int main(void) {
int i, j, k, s, p, q, sp, r, c = 1, nos = 13;
for (i = 1; c
7/24/2019 Number Pattern Challenges
6/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 6
}
if ((i % 2) != 0) {
printf("\n");
nos--;
}
}
for (k = 3; k >= 1; k--) {
if ((k % 2) != 0) {
for (sp = nosp; sp >= 1; sp--) { // for the spacing factor.
printf(" ");
}
for (r = 1; r j-i
where
j= inner loop indexi= outer loop index
Back to top
End of Question6 Start of Question7
7. Write a C program to print the following pattern:
77777777777
7
7
7
7
7
7
7
7
77
Program:
#include
int main(void) {
int i, j;
for (i = 11; i >= 1; i--) {
for (j = 1; j
7/24/2019 Number Pattern Challenges
7/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 7
8. Write a C program to print the following pattern:
1 1
1 0 1 0
1 0 1 1 0 1
1 0 1 0 1 0 1 0
1 0 1 0 1 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 1 0 1 0 1
1 0 1 0 1 0 1 0
1 0 1 1 0 1
1 0 1 0
1 1
Program:
#include
int main(void) {
int i,j,k,s,nos=11;
for (i=1; i
7/24/2019 Number Pattern Challenges
8/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 8
3 6 9
2 4
1
Program:
#include
int main(void) {
int i,j;
for (i=1; i
7/24/2019 Number Pattern Challenges
9/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 9
}
Download Code
Explanation:This c an be seen as two right angle triangles sharing the same base which is
composed of 0s n 1s. The first column is filled with 1s and rest with 0s
Back to topEnd of Question10
Over 1600 professionals follow Interview Mantra.
Enter your email address Send email updates
About th e Aut hor: This post was written by Utsav Banerjee. You can reach Utsav on email
Tagged as: pattern programs
180 comments
Leave a message...
Best Community Share
muthprabha
*
* *
* * *
* * * *
19 1
guest
simple c++ program for the below pattern pls
1
1 2 11 2 3 2 1
1 2 1
1
24 2
trushar
if n=3 & ch=A
B
C E
H M U
H C
K
dothis pattern using fibo ......
5
SHREE
CAN U GIVE THE CODING FOR THE ABOVE PATTERN PLEASE
URGENT
4 2
Neethu
#include
int main() {
/* c taken for columns */
int i, j, c = 9, m, k;
for i = 1 i
7/24/2019 Number Pattern Challenges
10/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 10
/* k is used for spaces */
for (k = 1; k
7/24/2019 Number Pattern Challenges
11/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 1
nivya
i have a problem to print the following pattern
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
17 1
sourav
#include#include
void main()
{
int i,j,n;
clrscr();
int k=1;
printf("Enter no of line : ");
scanf("%d",&n);
for(i=0;i
1
see more
S.V.Ramana
hi
ainam
good morning
this is code for ur output
printing like
1
2 3
4 5 6
7 8 9 10
#include
#include
void main()
{
int i,j,n;
clrscr();int k=1;
" "
10
n v mahesh
#include
#incldue
void main()
{
int i,j,k=0;
clrscr();
for(i=1;i
7/24/2019 Number Pattern Challenges
12/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 12
}
getch();
}
jasp ree t pan nu
please help me print the following pattern ;
123454321
1234 4321
123 321
12 21
1 1
10
ravi
pls help me...
how can we make this pattern.
if n=5(n is inputted by user.)
then this pattern will be displayed.
55555
54444
54333
54322
54321
10
kusum
how to print the pattern
a. 1
2 3
4 5 6
7 8 9 10
b 1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
plese help me
9
shweta
#include
int main()
{
int n, i, c, a = 1;
printf("Enter the number of row s of Floyd's triangle to print\n");
scanf("%d", &n);
for (i = 1; i
7/24/2019 Number Pattern Challenges
13/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 13
12
123
1234
12345
. . . . . . . . .
in OPEN SOURCE PROGRAMMING
22 3
Omkar T
In open source program in the sense what?
4
Ravikumar
write a c program to print the numbers in the given below formatt?
4 4
3 3
2 2
1 1
0
1 1
2 2
3 3
4 4
8
saranya
plse help me in this program
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
8
Nikhil Nambiar
main()
{
int i,j;
for(i=1;i
7/24/2019 Number Pattern Challenges
14/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 14
* *
*
* *
* *
6
Vinod Mishra
Can you give code for
1
1 1
1 2 11 3 3 1
1 4 6 4 1
and so on,
thank you.
6
Ram Airan
#include
void main()
{
int num=1, rows;
printf("Enter number of rows: ");
scanf("%d", &rows);
do{
printf("%d\n",num);
num*=11;
}while(rows>0);
getch();
}
2
joel
sir i have this pattern so please help me
1
22
333
4444
55555
6
n v mahesh
#include
#incldue
void main()
{
int i,j;
clrscr();
for(i=1;i
7/24/2019 Number Pattern Challenges
15/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 15
NAVEEN
Write a program to print the following pattern:
1
12
123
1234
12345
6
Milind Deshkar
i want to know the solution of this numerical pattern
1
2 3
4 5 6
7 8 9 10
5
Shimul
#include
#include
int main()
{
int i,a,j,b=1;
printf("Enter a Size = ");
scanf("%d",&a);
for(i=1;i
7/24/2019 Number Pattern Challenges
16/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 16
}
n v mahesh
#include
#incldue
void main()
{
int i,j,k=0;
clrscr();
for(i=1;i
7/24/2019 Number Pattern Challenges
17/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 17
printf("%d",i);
printf("\n");
}
getch();
}
4
bharat
#includevoid main(){int num=1, rows;printf("Enter number of rows:
");scanf("%d",
&rows);do{printf("%d\n",num);num*=11;}while(rows>0);getch();}
Like
Reply
1
Naveen1728
main()
{
int i,j,n,k;
clrscr();
for(i=1;i
7/24/2019 Number Pattern Challenges
18/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
www.interviewmantra.net/2009/11/10-number-pattern-programs.html 18
Crazy145_romi
give me source code for this pattern
1234 4321
12 3 321
12 21
1 1
6 1
S.V.Ramana
hi
ay
i have code 4 your output
let it check
#include
#include
void main()
{
int i,j,n;
clrscr();
int k=1;
printf("Enter no of line : ");
scanf("%d",&n);
for(i=0;i
7/24/2019 Number Pattern Challenges
19/19
9/5/13 10 Challenging number pattern programs in C | Interview Mantra
Load more comments
sanjay kamdar
how i print following output... plz immediately solve my problem guys... i have an exam
tomorrow...
1
2 3
4 5 6
7 8
9
5 1
Bansalshubham257
give the coding of
*
* *
* * *
* * * *
2
tarun
Hey, can please anyone solve this-
in input is 4 then:
1
1 2
3 4 5
12 13 14 15
where next line begins with the sum of previous line's elements and increased by 1.
2
P R E V I O U S P O S T :You may be working for the Sun, but you are no exceptio n
N E X T P O S T : Using Google Docs Template for Resume
http://www.interviewmantra.net/2009/11/google-docs-template-resume.htmlhttp://www.interviewmantra.net/2009/11/you-may-be-working-for-sun-but-you-are.htmlhttp://interviewmantra.disqus.com/10_challenging_number_pattern_programs_in_c/latest.rsshttp://disqus.com/