Sei sulla pagina 1di 71

Home About Contact Facebook Page Calendar Interview Questions

C C++ HR Java

Interview Tips Subscribe

10 Challenging star pattern programs in C


by Utsav Banerjee on October 19, 2009

i 23 Votes

Computer languages are not as easy as human languages, they need you to become a computer yourself, think like a computer and write an algorithm. Computer programs are fun if you take them up as a challenge, as unsolved puzzles. There is lot of fun in taking up the challenge, understanding the problem, writing an algorithm, writing a program and most importantly running the program and obtaining required output. Here are few challenging C program questions for you. Lets see how many of them you would be able to write without seeing the program solution given below. These questions are to print patterns using asterisk(star) character. Comment below if you have tougher pattern questions.

Also read Number Pattern Programs


1. Write a C program to print the following pattern:
2. 3. 4. 5. * * * * * * * *

* *

6. Write a C program to print the following pattern:


7. * * 8. * * * * * * 9. * * * * * * * * * * 10.* * * * * * * * * * *

11. Write a C program to print the following pattern:


12.* 13. 14.* 15. 16.* 17. 18.* 19. 20.* * * * * * * * * * * * * * * * * * * * * * * * *

21. Write a C program to print the following pattern:


22.* * * * *

23. * * * * 24. * * * 25. * * 26. * 27. * * 28. * * * 29. * * * * 30.* * * * *

31. Write a C program to print the following pattern:


32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* * * * * * * * *

* * *

43. Write a C program to print the following pattern:


44. 45. 46. 47. 48. 49. 50. * * * * * * * * * * * * * * *

51. Write a C program to print the following pattern:


52.* 53.* 54.* 55.* 56.* 57.* 58.* 59.* 60.* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

61. Write a C program to print the following pattern:


62.* * * * * * * * * 63. * * * * * * * 64. * * * * * 65. * * * 66. * * * * * 67. * * * * 68. * * * 69. * * 70. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

71. Write a C program to print the following pattern:


72. 73. 74. 75.* 76.* 77.* 78.* 79.* 80.* 81.* 82.* 83.* 84. 85. 86. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

87. Write a C program to print the following pattern:


88.* 89. 90. 91. 92. 93. 94. 95. 96.* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* * * * *

1. Write a C program to print the following pattern:


* * * * * * * * *

Program:
/* This is a simple mirror-image of a right angle triangle */ #include int main() { char prnt = '*'; int i, j, nos = 4, s; for (i = 1; i <= 5; i++) { for (s = nos; s >= 1; s--) { factor printf(" "); } for (j = 1; j <= i; j++) { printf("%2c", prnt); } printf("\n"); --nos; // Controls the spacing factor }

// Spacing

return 0;

Download Code Back to top

2. Write C program to print the following pattern:


3. * * 4. * * * * * * 5. * * * * * * * * * * * * * * * * * * * * *

Program:
#include int main() { char prnt = '*'; int i, j, k, s, c = 1, nos = 9; for (i = 1; c <= 4; i++) { // As we want to print the columns in odd sequence viz. 1,3,5,.etc if ((i % 2) != 0) { for (j = 1; j <= i; j++) { printf("%2c", prnt); } for (s = nos; s >= 1; s--) { //The spacing factor if (c == 4 && s == 1) { break; } printf(" "); } for (k = 1; k <= i; k++) { if (c == 4 && k == 5) { break; } printf("%2c", prnt); } printf("\n"); nos = nos - 4; // controls the spacing factor ++c; } } return 0; }
Download Code Back to top

6. Write C program to print the following pattern:


7. * 8. 9. * 10. 11.* 12. 13.* 14. * * * * * * * * * * * * * * * * * * * * * * * * *

Program:
#include

int main() { char prnt = '*'; int i, j, k, s, p, r, nos = 7; for (i = 1; i <= 5; i++) { for (j = 1; j <= i; j++) { if ((i % 2) != 0 && (j % 2) != 0) { printf("%3c", prnt); } else if ((i % 2) == 0 && (j % 2) == 0) { printf("%3c", prnt); } else { printf(" "); } } for (s = nos; s >= 1; s--) { // for the spacing factor printf(" "); } for (k = 1; k <= i; k++) { //Joining seperate figures if (i == 5 && k == 1) { continue; } if ((k % 2) != 0) { printf("%3c", prnt); } else { printf(" "); } } printf("\n"); nos = nos - 2; // space control } nos = 1; // remaining half.. for (p = 4; p >= 1; p--) { for (r = 1; r <= p; r++) { if ((p % 2) != 0 && (r % 2) != 0) { printf("%3c", prnt); } else if ((p % 2) == 0 && (r % 2) == 0) { printf("%3c", prnt); } else { printf(" "); } } for (s = nos; s >= 1; s--) { printf(" "); } for (k = 1; k <= p; k++) { if ((k % 2) != 0) { printf("%3c", prnt); } else { printf(" "); } } nos = nos + 2; // space control printf("\n"); } return 0; }
Download Code

Explanation: This can be seen as an inverted diamond composed of stars. It can be noted that the composition of this figure follows sequential pattern of consecutive stars and spaces. In case of odd row number, the odd column positions will be filled up with *, else a space will be spaced and vice-versa in case of even numbered row. In order to achieve this we will construct four different right angle triangles aligned as per the requirement.
Back to top

15. Write a C program to print the following pattern:


16.* * * * * 17. * * * * 18. * * * 19. * * 20. * 21. * * 22. * * * 23. * * * *

Program:
#include int main() { char prnt = '*'; int i, j, s, nos = 0; for (i = 9; i >= 1; (i = i - 2)) { for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { if ((i % 2) != 0 && (j % 2) != 0) { printf("%2c", prnt); } else { printf(" "); } } printf("\n"); nos++; } nos = 3; for (i = 3; i <= 9; (i = i + 2)) { for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { if ((i % 2) != 0 && (j % 2) != 0) { printf("%2c", prnt); } else { printf(" "); } } nos--; printf("\n");

} return 0;

Download Code Back to top

24. Write a C program to print the following pattern:


25. 26. 27. 28. 29. 30. 31. 32. 33. 34. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* * *

Program:
#include int main() { char prnt = '*'; int i, j, k, s, nos = 4; for (i = 1; i <= 5; i++) { for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { printf("%2c", prnt); } for (k = 1; k <= (i - 1); k++) { if (i == 1) { continue; } printf("%2c", prnt); } printf("\n"); nos--; } nos = 1; for (i = 4; i >= 1; i--) { for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { printf("%2c", prnt); } for (k = 1; k <= (i - 1); k++) { printf("%2c", prnt); } nos++; printf("\n"); } nos = 3; for (i = 2; i <= 5; i++) { if ((i % 2) != 0) { for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { printf("%2c", prnt); } } if ((i % 2) != 0) { printf("\n"); nos--; } } return 0; }
Download Code Back to top

35. Write a C program to print the following pattern:


36. 37. 38. 39. 40. 41. * * * * * * * * * * * * * * *

* /*

Program:

This can be seen as two right angle triangles sharing the same base which is modified by adding few extra shifting spaces */ #include // This function controls the inner loop and the spacing // factor guided by the outer loop index and the spacing index. int triangle(int nos, int i) { char prnt = '*'; int s, j; for (s = nos; s >= 1; s--) { // Spacing factor printf(" "); } for (j = 1; j <= i; j++) { //The inner loop printf("%2c", prnt); } return 0; } int main() { int i, nos = 5; //draws the upper triangle for (i = 1; i <= 4; i++) { triangle(nos, i); //Inner loop construction nos++; // Increments the spacing factor printf("\n"); } nos = 7; //Draws the lower triangle skipping its base. for (i = 3; i >= 1; i--) { int j = 1; triangle(nos, i); // Inner loop construction nos = nos - j; // Spacing factor printf("\n"); } return 0; }
Download Code Back to top

42. Write a C program to print the following pattern:


43.* 44.* 45.* 46.* 47.* 48.* 49.* 50.* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Program:
#include int main() { char prnt = '*'; int i, j, k, s, nos = -1; for (i = 5; i >= 1; i--) { for (j = 1; j <= i; j++) { 1; s--) { printf(" ");

printf("%2c", prnt); } for (s = nos; s >=

} nos = 5; for (i = 2; i <= 5; i++) { for (j = 1; j <= i; j++) { 1; s--) { printf(" "); } for (k = 1; k <= i; k++) { if (i == 5 && k == 5) { break; } printf("%2c", prnt); } nos = nos - 2; printf("\n"); } return 0; }
Download Code Back to top

} for (k = 1; k <= i; k++) { if (i == 5 && k == 5) { continue; } printf("%2c", prnt); } nos = nos + 2; printf("\n");

printf("%2c", prnt); } for (s = nos; s >=

51. Write a C program to print the following pattern:


52.* * * * * * * * * 53. * * * * * * * 54. * * * * * 55. * * * 56. * * * * * 57. * * * * 58. * * * 59. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Program:
#include int main() { char prnt = '*'; int i, j, k, s, sp, nos = 0, nosp = -1; for (i = 9; i >= 3; (i = i - 2)) { for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { printf("%2c", prnt); } for (sp = nosp; sp >= 1; sp--) { printf(" "); }

for (k = 1; k <= i; k++) { if (i == 9 && k == 1) { continue; } printf("%2c", prnt); } nos++; nosp = nosp + 2; printf("\n"); } nos = 4; for (i = 9; i >= 1; (i = i - 2)) { for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { printf("%2c", prnt); } nos++; printf("\n"); } return 0; }
Download Code Back to top

60. Write a C program to print the following pattern:


61. 62. 63. 64.* 65.* 66.* 67.* 68.* 69.* 70.* 71.* 72.* 73. 74. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Program:
#include /* * nos = Num. of spaces required in the triangle. * i = Counter for the num. of charcters to print in each row * skip= A flag for checking whether to * skip a character in a row. * */ int triangle(int nos, int i, int skip) { char prnt = '*'; int s, j; for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { if (skip != 0) { if (i == 4 && j == 1) { continue; } }

printf("%2c", prnt); } return 0;

int main() { int i, nos = 4; for (i = 1; i <= 7; (i = i + 2)) { triangle(nos, i, 0); nos--; printf("\n"); } nos = 5; for (i = 1; i <= 4; i++) { triangle(1, i, 0); //one space needed in each case of the formation triangle(nos, i, 1); //skip printing one star in the last row. nos = nos - 2; printf("\n"); } nos = 1; for (i = 3; i >= 1; i--) { triangle(1, i, 0); triangle(nos, i, 0); nos = nos + 2; printf("\n"); } nos = 1; for (i = 7; i >= 1; (i = i - 2)) { triangle(nos, i, 0); nos++; printf("\n"); } return 0; }
Download Code Back to top

75. Write a C program to print the following pattern:


76.* 77. 78. 79. 80. 81. 82. 83. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* * * *

Program:
#include /* * nos = * i = * skip= * * */ Num. of spaces required in the triangle. Counter for the num. of characters to print in each row A flag for check whether to skip a character in a row.

int triangle(int nos, int i, int skip) {

char prnt = '*'; int s, j; for (s = nos; s >= 1; s--) { printf(" "); } for (j = 1; j <= i; j++) { if (skip != 0) { if (i == 9 && j == 1) { continue; } } if (i == 1 || i == 9) { printf("%2c", prnt); } else if (j == 1 || j == i) { printf("%2c", prnt); } else { printf(" "); } } return 0; } int main() { int i, nos = 0, nosp = -1, nbsp = -1; for (i = 9; i >= 1; (i = i - 2)) { triangle(nos, i, 0); triangle(nosp, i, 1); triangle(nbsp, i, 1); printf("\n"); nos++; nosp = nosp + 2; nbsp = nbsp + 2; } nos = 3, nosp = 5, nbsp = 5; for (i = 3; i <= 9; (i = i + 2)) { triangle(nos, i, 0); triangle(nosp, i, 1); triangle(nbsp, i, 1); printf("\n"); nos--; nosp = nosp - 2; nbsp = nbsp - 2; } return 0; }
Download Code Back to top

Over 1600 professionals follow Interview Mantra.


Top of Form

Enter your

interview mantra

en_US

Send email updates


Bottom of Form

Get Shareaholic

About the Author: This post was written by Utsav Banerjee. You can reach Utsav on email at fugitiveland@gmail.com

2,220 readers have already subscribed to email updates!


Top of Form

Enter your email address:

interview mantra

en_US

Subscribe
Bottom of Form

Tagged as: pattern programs

Disqus Login About Disqus

Like Dislike

Glad you liked it. Would you like to share?


Facebook Twitter

Share No thanks

Sharing this page Thanks! Close Login

Add New Comment

Post as Image

Sort by popular now

Showing 100 of 121 comments


Abiha_kazmi32 1 comment collapsed Collapse Expand tell me the code of following * *** **** ***** **** *** *

A Like Reply 2 months ago 4 Likes F

Snehalvjadhav 2 comments collapsed Collapse Expand tell me the code of following pattern. * * * * * * * * *

A Like Reply 3 months ago 4 Likes F

Mansi 1 comment collapsed Collapse Expand

#include<stdio.h> main() { int i,j,k,n; printf(how many lines you want to enter:"); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=n;j>=i;j--) { printf(" "); } for(k=1;k<=i-1;k++) { printf("*"); printf(" "); } printf("\n"); } for(i=1;i<=n;i++) { for(j=1;j<=i-1;j++) { printf(" "); } for(k=n;k>=i;k--) { printf("*"); printf(" "); } printf("\n"); } }</stdio.h>

A Like Reply 3 months ago in reply to Snehalvjadhav 3 Likes F

Hari 8 comments collapsed Collapse Expand

how can i print '**'s four sides of screen???? example like this............ *********************************************************************** * * * * * * * * * * * * * * * * * * * * * *********************************************************************** ** can any 1 help me??????please.......

A Like Reply 2 months ago 2 Likes F

Jayesh5101992sapkale 3 comments collapsed Collapse Expand can U give your Email id I Will Send u program solution b-coz content not Fit on it,,,,,,,,,,,,,,,,If You have Already Solved this problem then Very Good Try...........

A Like Reply 2 weeks ago

in reply to Hari F

0 Like Jayesh5101992sapkale 2 comments collapsed Collapse Expand int first_term=1; void main() { int a[100][100]; int c=1,i=0,j=0,k=0,m=0,n=0,x=0; clrscr(); printf("Enter Rows and columns for the square matrix \n"); scanf("%d",&n); x=n; while(n>=1) { for(k=0;k<n;k++)<br>if(first_term){a[m][k+m]=c++;} else{a[m][k+m]=0;} for(k=1;k<n;k++)<br>if(first_term){a[k+m][n-1+m]=c++;} else{a[k+m][n-1+m]=0;} for(k=n-2;k>=0;k--) if(first_term){a[n-1+m][k+m]=c++;} else{a[n-1+m][k+m]=0;} for(k=n-2;k>0;k--) if(first_term){a[k+m][m]=c++;} else{a[k+m][m]=0;} if(x==n){ first_term=0;} n-=2; m++; }

for(i=0;i<x;i++)<br>{ for(j=0;j<x;j++)<br>{ if(a[i][j]==0){printf(" else{printf(" *") ;} }

");}

printf("\n"); } getch(); }</x;j++)<br></x;i++)<br></n;k++)<br></n;k++)<br>


A Like Reply 2 weeks ago in reply to Jayesh5101992sapkale F

0 Like Jayesh5101992sapkale 1 comment collapsed Collapse Expand Remove all last line from it

A Like Reply 2 weeks ago in reply to Jayesh5101992sapkale F

0 Like Jayesh5101992sapkale 1 comment collapsed Collapse Expand #include <conio.h> #include <stdio.h> int first_term=1;

void main() { int a[100][100];int c=1,i=0,j=0,k=0,m=0,n=0,x=0;clrscr(); printf("Enter the number of rows and columns for the square matrix \n");scanf("%d",&n);x=n;</stdio.h></conio.h>

A Like Reply 2 weeks ago in reply to Hari F

0 Like Jayesh5101992sapkale 2 comments collapsed Collapse Expand Hi Hari ,,,,,Check this code in c language..........if any Error Plz Fix it.... Code: #include <conio.h>#include <stdio.h>int first_term=1;void main(){int a[100] [100];int c=1,i=0,j=0,k=0,m=0,n=0,x=0;clrscr();printf("Enter the number of rows and columns for the square matrix \n");scanf("%d",&n);x=n;while(n>=1) {for(k=0;k<n;k++)if(first_term){a[m][k+m]=c++;}else{a[m] [k+m]=0;}for(k=1;k<n;k++)if(first_term){a[k+m][n-1+m]=c++;}else{a[k+m][n1+m]=0;}for(k=n-2;k>=0;k--)if(first_term){a[n-1+m][k+m]=c++;}else{a[n-1+m] [k+m]=0;}for(k=n-2;k>0;k--)if(first_term){a[k+m][m]=c++;}else{a[k+m] [m]=0;}if(x==n){first_term=0;}n-=2;m++;}for(i=0;i<x;i++){for(j=0;j<x;j++){ ");} ="" ;}}printf("\n");}getch();}="" else{printf("="" if(a[i][j]="=0){printf("" ="" *")=""></x;i++){for(j=0;j<x;j++){ ></n;k++)if(first_term){a[m][k+m]=c+ +;}else{a[m][k+m]=0;}for(k=1;k<n;k++)if(first_term){a[k+m][n-1+m]=c+ +;}else{a[k+m][n-1+m]=0;}for(k=n-2;k></stdio.h></conio.h>

A Like Reply 2 weeks ago in reply to Hari

0 Like

Jayesh5101992sapkale 1 comment collapsed Collapse Expand sorry this is not suitable.,,,,I will provide in to parts

A Like Reply 2 weeks ago in reply to Jayesh5101992sapkale F

0 Like Sarvesh445 1 comment collapsed Collapse Expand void main() { for(int i=1;i<=n;i++)//n is any integer value for(int j=1;j<=n;j++) if(i==1||i==n||j==1||j==n) print("*"); }

A Like Reply 1 month ago in reply to Hari F

0 Like abc 2 comments collapsed Collapse Expand give me the code of following pattern *

*** ***** *******


A Like Reply 2 months ago 2 Likes F

Sarvesh445 1 comment collapsed Collapse Expand void main() { int a,b; a=b=7/2+1;//n=no of rows..n+(n-1)=7(for 4 rows) for(int i=1;i<=4;i++) { for(int j=1;j<=7;j++) { if(j>=a&&j<=b) print("*"); } a--; b++; } }

A Like Reply 1 month ago in reply to abc F

0 Like Rajsharmaj2ee 2 comments collapsed Collapse Expand give me the code of following character A B C D E F G F E D C B A A B C D E F F E D C B A

A A A A A

B C D E B C D B C B

E D C B A DC B A C B A B A A

pls reply sir code regards Raj vishwakarma


A Like Reply 1 month ago 1 Like F

Bindu Kamboj 1 comment collapsed Collapse Expand #include<stdio.h> #include<conio.h> void main() int i,j,k,l,a=1,d=2,x; char p='A'; for(i=1;i<=6-1;i++) { for(j=1;j<=7-i;j++) { printf("%c",p); p++; } x=a+(i-1)*d; for(k=1;k<=x;k++) { printf(" "); } for(l=1;l<=7-i;l++) { printf("%c",p-1); p--; } printf("\n"); } getch(); }

</conio.h></stdio.h>

A Like Reply 2 weeks ago in reply to Rajsharmaj2ee F

0 Like S.V.Ramana 1 comment collapsed Collapse Expand This is code for Loveneesh's output like ***** **** *** ** * #include #include void main() { int i,j,n; clrscr(); printf("Enter n value"); scanf("%d",&n); for(i=n;i>0;i--) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } getch(); }

A Like Reply 4 months ago 4 Likes

vidhya 1 comment collapsed Collapse Expand can u tell me how to put tis pattern * *** ***** *** *

A Like Reply 7 months ago 7 Likes F

Rohitarg91 1 comment collapsed Collapse Expand great


A Like Reply 3 months ago 2 Likes F

abc 1 comment collapsed Collapse Expand give me the code of following pattern 1 11 121 1331 14641

A Like Reply 2 months ago 1 Like F

ATUBH BHAWARE 2 comments collapsed Collapse Expand plz someone tell me program for following output ** **** ****** ******** ********** ******** ****** **** **

A Like Reply 6 months ago 3 Likes F

Suhani6yadav 1 comment collapsed Collapse Expand #include<stdio.h> main() { int n, c, k, space = 1; printf("Enter number of rows\n"); scanf("%d",&n); space = n - 1; for ( k = 1 ; k <= n ; k++ )

{ for ( c = 1 ; c <= space ; c++ ) printf(" "); space--; for ( c = 1 ; c <= 2*k-1 ; c++) printf("*"); printf("\n"); } space = 1; for ( k = 1 ; k <= n - 1 ; k++ ) { for ( c = 1 ; c <= space; c++) printf(" "); space++; for ( c = 1 ; c <= 2*(n-k)-1 ; c++ ) printf("*"); printf("\n"); } return 0; }</stdio.h>

A Like Reply 1 month ago in reply to ATUBH BHAWARE F

0 Like anonymous 1 comment collapsed Collapse Expand * * * * *

* * * * no. of rows to be entered by user ?


A Like Reply 2 months ago 1 Like F

supantha kumar pal 4 comments collapsed Collapse Expand plz tell the code.... 1 23 456 7 8 9 10

A Like Reply 6 months ago 3 Likes F

Bindu Kamboj 1 comment collapsed Collapse Expand #include<stdio.h> void main() { int i,j,a=1; for(i=1;i<=4;i++) { for(j=1;j<i+1;j++)<br> { printf("%d",a); a++; } printf("\n"); }

getch(); }</i+1;j++)<br></stdio.h>

A Like Reply 2 weeks ago in reply to supantha kumar pal F

0 Like subbanaidu 1 comment collapsed Collapse Expand #include<stdio.h> void main() {int i,j,temp=0; clrscr(); for(i=0;i<n;i++)<br>for(j=0;j<n;j++)<br>{ printf("%d",temp); temp++; } } </n;j++)<br></n;i++)<br></stdio.h>

A Like Reply 2 months ago in reply to supantha kumar pal F

0 Like Dharmu1994 1 comment collapsed Collapse Expand #include<stdio.h> main() { int n, c, k,p=1; printf("Enter number of rows\n");

scanf("%d",&n); for ( c = 1 ; c <= n ; c++ ) { for( k = 1 ; k <= c ; k++ ) { printf("%d",p); p=p+1; } printf("\n"); } return 0; }</stdio.h>

A Like Reply 3 months ago in reply to supantha kumar pal F

0 Like rashmi 1 comment collapsed Collapse Expand plz tell me coding ****** and send me code on my email-id * * my id smile_rashmicharjan@rediff.com * * ******

A Like Reply 4 months ago 1 Like F

R.Mahalakshmi 2 comments collapsed Collapse Expand i need simple c program to print like a following pattern * *** *****

*** *

A Like Reply 4 months ago 1 Like F

Dineshrockzzz8 1 comment collapsed Collapse Expand class pattern21st { public static void main () { for(int i = 1 ; i <=5 ; i++) { for(int j = 1 ; j <= i ; j++) { System.out.print( "*" + " " ); } System.out.println(); } for(int i = 4 ; i >=1 ; i--) { for(int j = 1 ; j <= i ; j++) { System.out.print( "*" + " " ); } System.out.println(); } } }

A Like Reply 2 weeks ago in reply to R.Mahalakshmi F

0 Like

jasleen 1 comment collapsed Collapse Expand can u please give me a coding of this pattern? * ** ** *******

A Like Reply 5 months ago 1 Like F

jyotish 1 comment collapsed Collapse Expand plz someone tell me program for following output abcdedcba abcd dcba abc cba ab ab aa

A Like Reply 5 months ago 1 Like F

ATUBH BHAWARE 1 comment collapsed Collapse Expand plz someone tell me program for following output * ** ***

*****

A Like Reply 6 months ago 1 Like F

sai 1 comment collapsed Collapse Expand to print as *** ** *


A Like Reply 6 months ago 1 Like F

saurabh chopra 1 comment collapsed Collapse Expand sir,How can we print stars in a circle?

A Like Reply 6 months ago 1 Like F

pratik 1 comment collapsed Collapse Expand

plz help mi to write ths pattern program.. ***************** ** ** ****** ****** 1** ** **** **** ** ***********

A Like Reply 10 months ago 1 Like F

Pramod 1 comment collapsed Collapse Expand * ** ** ******


A Like Reply 11 months ago 1 Like F

mathapelo 1 comment collapsed Collapse Expand 8 Write a separate algorithm for a program to output each of the following patterns [Note: There are four triangles of stars labelled (a) (b) (c) (d). Each triangle consists of ten lines of stars. Starting from line 1 to 10, the number of stars either increases by 1 from 1 to 10 or decreases by 1 from 10 to 1]: (a) (b) (c) (d)

* ********** ********** * ** ********* ********* ** *** ******** ******** *** **** ******* ******* **** ***** ****** ****** ***** ****** ***** ***** ****** ******* **** **** ******* ******** *** *** ******** ********* ** ** ********* ********** * * **********

A Like Reply 11 months ago 1 Like F

Utsav Banerjee 1 comment collapsed Collapse Expand As the author of the post , I would like to request everyone not to ask for ready made codes as I am strictly against spoon feeding. Please try out the problem yourself post your code in pastebin.com n refer us the link so that we can verify your code, and help you solve the riddle. Thanking You Utsav Banerjee

A Like Reply 11 months ago 1 Like F

Sahil 2 comments collapsed Collapse Expand tell me the code of this 1 23

456 7 8 9 10

A Like Reply 11 months ago 1 Like F

Bindu Kamboj 1 comment collapsed Collapse Expand #include<stdio.h> void main() { int i,j,a=1; for(i=1;i<=4;i++) { for(j=1;j<i+1;j++)<br> { printf("%d",a); a++; } printf("\n"); } getch(); } </i+1;j++)<br></stdio.h>

A Like Reply 2 weeks ago in reply to Sahil F

0 Like sridhar 1 comment collapsed Collapse Expand The credit of this post goes to Utsav Banerjee.. Good work Utsav! Editor, Interview Mantra

A Like Reply 2 years ago 1 Like F

Ridzi0207 1 comment collapsed Collapse Expand plz tell me the code for ******* ******* *** * *** *******

A Like Reply 1 week ago F

0 Like Nkkoolguy 1 comment collapsed Collapse Expand * **

* **** *

** * ******** * ** * **** * ** *Plz tell the code to get this pattern


A Like Reply 2 weeks ago F

0 Like Bhomit Davara 2 comments collapsed Collapse Expand Give me the code of following pattern : when we input : 3 6 5 3 2 4 1

A Like Reply 3 weeks ago F

0 Like Bindu Kamboj 1 comment collapsed Collapse Expand #include<stdio.h> void main() { int i,j,a=6; for(i=1;i<=3;i++) { for(j=1;j<i+1;j++)<br> { printf("%d",a ); a--; } printf("\n"); } getch(); }</i+1;j++)<br></stdio.h>

A Like Reply 2 weeks ago in reply to Bhomit Davara F

0 Like Ajay 1 comment collapsed Collapse Expand please giv me the code for following pattern! 1 11 21 1211 111221

312211 13112221

A Like Reply 1 month ago F

0 Like Grissar 2 comments collapsed Collapse Expand Would someone be able to help with creating a hollow triangle in Java looking like this: ----*-------*-*-----*---*---*-----*-********* Where the - equals a space. A user enters a number and the triangle height = the number. I have this code so far but I can't get any further. Not even sure if I'm on the right track anymore: http://pastebin.com/rUrKaVW5 Thanks in advance.

A Like Reply 1 month ago F

0 Like Grissar 1 comment collapsed Collapse Expand The drawing didn't come out ok. So, here's a photo.

A Like Reply 1 month ago in reply to Grissar F

0 Like

deepak singla 1 comment collapsed Collapse Expand give me the code of following pattern 1 01 101 0101 10101

A Like Reply 1 month ago F

0 Like Bschinku 1 comment collapsed Collapse Expand thanx dear


A Like Reply 3 months ago F

0 Like Sudhir 1 comment collapsed Collapse Expand please can you provide the code for following pattern in C++ H H EEEEE L L OOOOH H E L O OH H E L L OHHHHH EEEEE L L O OH H L L O OH H E L L O OH H EEEEE LLLLL LLLLL OOOOO L O E

its a little distorted but you must have understood what i am trying to printcan mail me at SUDHIR14789@gmail.com

A Like

Reply 3 months ago F

0 Like siva 1 comment collapsed Collapse Expand so diff to get!!!


A Like Reply 3 months ago F

0 Like Manish Prajapati1991 1 comment collapsed Collapse Expand please give me help for printing below pattern. if inputn is 5 then 1 2 3 4 516 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

A Like Reply 4 months ago F

0 Like KALE SOMNAH 3 comments collapsed Collapse Expand PLS tell me code to wether the given strig s palioderm or not

A Like

Reply 4 months ago F

0 Like Bujji 1 comment collapsed Collapse Expand

Aim : to find whether given string is palindrome or not Input : accept a string Output : palindrome or not Program : #include<stdio.h> int main(void) { char st[20],rev[20]; int l=0,i; clrscr(); printf("enter a string");

scanf("%s",&st); for(;st[l]!='\0';l++); find length of a string*/ for(i=0;i<l;i++)<br> rev[i]=st[l-i-1]; rev[l]='\0'; for(i=0;i<l;i++)<br> { /*to reverse the string*/ /*to

if(st[i]!=rev[i]) /*to compare original string & reversed string*/ break; break the loop*/ } if(i==l) compare lengths of 2 srings*/ /*to /*to

printf("palindrome"); else

printf("not a palindrome");

} INPUT OUTPUT: enter a string madam palindrome

enter a string bunny not a palindrome </l;i++)<br></l;i++)<br></stdio.h>


A Like Reply 2 months ago in reply to KALE SOMNAH 1 Like F

Mallickanurag25 1 comment collapsed Collapse Expand #include<stdio.h> void main() { int r=0,x,y,z;

printf("Enter the number to be checked "); scanf("%d",&x); y=x; while (x!=0) { r=(r*10)+(x%10); x=x/10; z=r; } if (y==z) { printf("the given number is a pallindrome."); } else { printf("the given number is not a pallindrome."); } }</stdio.h>

A Like Reply 4 months ago in reply to KALE SOMNAH F

0 Like ankur loved 1 comment collapsed Collapse Expand this is not the optimized code this will use more memory

A Like Reply 4 months ago F

0 Like loveneesh 3 comments collapsed Collapse Expand

mirror image of this ***** **** *** ** *


A Like Reply 4 months ago F

0 Like Dineshrockzzz8 1 comment collapsed Collapse Expand class pattern1st { public static void main () { for(int i = 1 ; i <=5 ; i++) { for(int j = 1 ; j <= i ; j++) { System.out.print( "*" + " " ); } System.out.println(); } } }

A Like Reply 2 weeks ago in reply to loveneesh F

0 Like Dharmu1994 1 comment collapsed Collapse Expand

#include<stdio.h> void main() { int n, c, k; printf("Enter number of rows\n"); scanf("%d",&n); for ( c = 1 ; c <= n ; c++ ) { for( k = c ; k <= n ; k++ ) printf("*"); printf("\n"); } }</stdio.h>

A Like Reply 3 months ago in reply to loveneesh F

0 Like loveneesh 2 comments collapsed Collapse Expand ***** **** *** ** *


A Like Reply 4 months ago F

0 Like

Angad tomar 1 comment collapsed Collapse Expand for(i=n;i>0;i--) { printf(" "); for(j=1;j<=i;j++) { printf("*"); } printf("\n"); }

A Like Reply 2 weeks ago in reply to loveneesh F

0 Like loveneesh 1 comment collapsed Collapse Expand how can i print the pattern ***** **** *** ** *

A Like Reply 4 months ago F

0 Like

Vjy 1 comment collapsed Collapse Expand 1 141 13531 1357531 13531 141 1

A Like Reply 4 months ago F

0 Like jevie mar galaura 1 comment collapsed Collapse Expand i have problem in my codes please sent me and email on asterisk patterns please!!!!!!!!

A Like Reply 4 months ago F

0 Like sushant choudhary 1 comment collapsed Collapse Expand code to print the following pattern: 1 131 13531 1357531 13531 131 1

A Like

Reply 4 months ago F

0 Like jasleen 1 comment collapsed Collapse Expand above is not exact pattern may b some problem in printing the pattern is : there is three spaces and then star in first line in second line two spaces then star then one space and again star in third line one space one star then three spaces one star in fourth line seven stars.

A Like Reply 5 months ago F

0 Like jasleen 1 comment collapsed Collapse Expand can u please give me a coding of this pattern? *

A Like Reply 5 months ago F

0 Like Rajitha 1 comment collapsed Collapse Expand 1111111 1221

1331 141 1331 1221 1111111 can any one do this?????????


A Like Reply 5 months ago F

0 Like saurabh 1 comment collapsed Collapse Expand heloo friends your mind is very sharp becouse your programing is very dilicious

A Like Reply 5 months ago F

0 Like amit sisodiaa 1 comment collapsed Collapse Expand this is so goood for begainer

A Like Reply 5 months ago F

0 Like ajit sujit 1 comment collapsed Collapse Expand

ye s this is perfect .but it will not run properly so modify it now.


A Like Reply 5 months ago F

0 Like accesscode 2 comments collapsed Collapse Expand ***** **** *** ** * Try this>>>>>

A Like Reply 5 months ago F

0 Like Himkarjha2042 1 comment collapsed Collapse Expand #include<stdio.h> #include<conio.h> void main() { int i,j,; clrscr(); for(i=6;i>0;i--) { for(j=1;j<=i;j++) { printf("*"); }

printf("\n"); } getch(); }</conio.h></stdio.h>


A Like Reply 3 months ago in reply to accesscode 1 Like F

jadoo 1 comment collapsed Collapse Expand #include #include #include #include #include #include #include using namespace std; int main() { for(int i=1;i<=5;i++) { for(int j=1;j<=i;j++) { cout<<"**"; } cout<=1;i--) { for(int j=i;j>=1;j--) { cout<<"**"; } cout<<endl; } return 0; }

A Like

Reply 5 months ago F

0 Like nitesh 1 comment collapsed Collapse Expand this is the best for bigners

A Like Reply 6 months ago F

0 Like Ashu 1 comment collapsed Collapse Expand thanks . this is very helpful

A Like Reply 6 months ago F

0 Like Mahendra 1 comment collapsed Collapse Expand Hey Sushant Ur Code is Here now ,.....Mahendra(Mayur) #include #include void main() { int i,j,n; clrscr(); printf(\n Enter the number :);

scanf(%d,&n); for(i=n;i>0;i) { for(j=i;j<=n;j++) { printf("*"); } printf("\n"); } for(i=0;i<=n;i++) { for(j=i;j<n-1;j++) { printf("*"); } printf("\n"); } getch(); } /* Enter the number :5 * ** *** **** ***** **** *** ** * */

A Like Reply 6 months ago F

0 Like Aman 1 comment collapsed Collapse Expand code for the patern: 1 26 3 7 10

4 8 11 13 5 9 12 14 15 here it goes: #include #include void main() { int i,j,a,n; clrscr(); printf("\n Enter the no. of lines to be printed."); scanf("%d",&n); for(i=1;i<=n;i++) { printf("\n"); a=i; for(j=1;j<=i;j++) { printf("%d ",a); a=a+n-j; } } getch(); }

Enjoy budies...;)

A Like Reply 7 months ago F

0 Like Nikhil 1 comment collapsed Collapse Expand ***** ** ** ****

A Like Reply 7 months ago F

0 Like rishav 1 comment collapsed Collapse Expand sry dere was problm is pasting d code,,,,,,,,dis is ryt code VIDHYA #include int main() { int k,m,n,i,j,l; printf("enter the size of the prog:"); scanf("%d",&n); m=n; for(j=1;j<=n;j++) { if((j<=n/2+1)) { k=j*2-1; for(l=1;ln/2+1) { k=m-2; m=k; for(i=1;i<=k;i++) { printf("*"); } printf("\n"); } else { continue; }} return 0; }

A Like Reply 7 months ago

0 Like

rishav 1 comment collapsed Collapse Expand dis is ur code ,,,,,,,,,,,,VIDHYA #include int main() { int k,m,n,i,j,l; printf("enter the size of the prog:"); scanf("%d",&n); m=n; for(j=1;j<=n;j++) { if((j<=n/2+1)) { k=j*2-1; for(l=1;ln/2+1) { k=m-2; m=k; for(i=1;i<=k;i++) { printf("*"); } printf("\n"); } else { continue; }} return 0; }

A Like Reply 7 months ago F

0 Like

supantha kumar pal 2 comments collapsed Collapse Expand plz tell me of this code.. 1 12 123 1234 12345

A Like Reply 7 months ago F

0 Like Samadhan Nirali 1 comment collapsed Collapse Expand void main() { int i,j,k=1; for(i=1;i<=5;i++) { for(j=1;j<=k;j++) { printf("%d",j); } k++; printf("\n"); } getch(); }

A Like Reply 3 months ago in reply to supantha kumar pal F

0 Like

supantha kumar pal 1 comment collapsed Collapse Expand @preethi here is ur programme #include void main() { int i,j; for(i=1;i<=5;i++) { printf("\n"); for(j=1;j<=i;j++) printf("a "); } } and ur out put is... a aa aaa aaaa aaaaa

A Like Reply 7 months ago F

0 Like preethi 1 comment collapsed Collapse Expand tell me the code for a aa aaa

aaaa aaaaa

A Like Reply 7 months ago F

0 Like rishav 1 comment collapsed Collapse Expand here is your code ,,,,,,,,, shahnawaz #include int main() { int m,i,j,k,p; printf("enter the size of the program"); scanf("%d",&m); k=p=m; for(i=0;i<m;i++) { for(j=0;j<m;j++) { if(i<=j) { printf("%d",p); p--; }} p=k; printf("\n"); } return 0; }

A Like Reply 7 months ago F

0 Like

rishav 1 comment collapsed Collapse Expand #include int main() { int m,n,i,j; m=6; n=11; for(i=0;i<6;i++) { for(j=0;j<11;j++) { if(i<5&&j<2) printf("*"); else if(i==5) printf("*"); else continue; } printf("\n"); } return 0; } here is code for printing........... ** ** ** ** ** ***********

A Like Reply 7 months ago F

0 Like rishav 1 comment collapsed Collapse Expand

#include int main() { int m,i,j; printf("enter the size of program \n"); scanf("%d",&m); for(i=0;i<m;i++) { for(j=0;j<m;j++) { if(i<=j) printf("*"); } printf("\n"); } return 0;}

A Like Reply 7 months ago F

0 Like manali 1 comment collapsed Collapse Expand plz tell me how to print the following pattern? ****** ***** **** *** ** *

A Like Reply 7 months ago F

0 Like

shahnawaz 3 comments collapsed Collapse Expand plz help me to write this program 54321 5432 543 54 5

A Like Reply 7 months ago F

0 Like Saptapratim Bose 2 comments collapsed Collapse Expand for(j=1;j<=5;j++) { for(i=5;i,=j;i--) printf('i"); printf("\n"0; } Reply saptapratim Bose

A Like Reply 2 months ago in reply to shahnawaz F

0 Like Saptapratim Bose 1 comment collapsed Collapse Expand for(j=1;j<=5;j++) { for(i=5;i,=j;i--) printf('i"); printf("\n");

} Reply saptapratim Bose


A Like Reply 2 months ago in reply to Saptapratim Bose F

0 Like jyothi 1 comment collapsed Collapse Expand ** ** * ** **


A Like Reply 8 months ago F

0 Like cliff 1 comment collapsed Collapse Expand please help me with code that displays characters in form of asteriks eg L ** ** ** ** ***********

A Like Reply 8 months ago F

0 Like

santhosh 1 comment collapsed Collapse Expand @rajani jha #include main() { int i,j; for(j=4;j>=0;j--) { for(i=j*2;i>0;i=i-1) { printf("*"); } printf("\n"); } }

A Like Reply 10 months ago F

0 Like tejas chachad 1 comment collapsed Collapse Expand ****** ** ** ** ******


A Like Reply 10 months ago F

0 Like

tejas chachad 1 comment collapsed Collapse Expand hey i want to print ****** ** ** ** ******

A Like Reply 10 months ago F

0 Like rajani jha 1 comment collapsed Collapse Expand i want the hint for the program ********* ******** ****** **** ** **** ****** ******** *********

A Like Reply 10 months ago F

0 Like

rajani jha 1 comment collapsed Collapse Expand reallly nyc programming


A Like Reply 10 months ago F

0 Like

M Subscribe by email S RSS


http://w w w

Load more comments Trackback URL Previous post: Bugs can get you a software job Next post: Interview with The Working Geek

Search
Top of Form

partner-pub-0399 FORID:10

UTF-8

Search

w w w .interview m
Bottom of Form

Get Free Email Updates


Top of Form

Enter your email address:

interview mantra

en_US

Subscribe
Bottom of Form

Recent Entries

How a Last-Bencher scored 1440 in GRE Test How to choose the right college for Engineering How to beat nervousness in a job interview New year resolutions to help you find a job The ant and the grasshopper

Winners of C Quiz Contest and Key Interview with Karthik, an MS Graduate working for INTEL in the USA Update for C Quiz Challenge C Quiz Challenge prizes for fastest & correct response Tata Technologies hiring SAP developers

Recent Job Postings


Walkin interview in Bangalore for CATIA Engineer for Tata Technologies Ltd, Pune September 27, 2011 Walking for ProE Design Engineer at Tata Technologies Ltd., Pune September 27, 2011 Walkin for Design Engineer at Tata Technologies, Pune September 25, 2011 Technical Solution Architect at Tata Technologies Ltd. September 25, 2011 Solution Designer for Tata Technologies Ltd. September 25, 2011 Sr Sales Manager for Tata Technologies Ltd. September 25, 2011 SAP-ABAP developer for Tata Technologies Ltd. September 25, 2011 Manufacturing Simulation Engineer for Tata Technologies, Pune September 25, 2011 Sales Executive for Tata Technologies Ltd., Delhi September 25, 2011 Senior PLM Support Consultant for Tata Technologies Ltd., Bangalore September 25, 2011

Tag cloud
Announcements appraisal C c++
contest embedded systems
engineering

cpp interview questions c programs destructor Download eBook electrical

interview questions career career advice classes

Freshers functions hiring story Humor india infosys


Questions Interview Tips IT Java job job
naukri object oriented concepts off campus pattern

inspiration interview Interview

website LinkedIn linkedin tips medium difficulty

programs performance review placement pointers programming quiz resume templates Resume

Tips Tips vlsi

Recent Comments
Raavi Swami on C Interview Programs to print number patterns

anil

on C Interview Programs to print number patterns

Rupinder32bhinder or not

on C interview programs swap numbers, palindrome

Yogeshsudrik AMDOCS

on C, SQL, UNIX interview for experienced developer @

Physics Prakash

on How to write career objective for your resume


Interview Mantra

Interview Mantra on Facebook Blogroll


Code Explosion Interview Mantra- India PSD to HTML Rock Solutions Want to add your website here?

2011 Interview Mantra All Rights Reserved Get smart with the Thesis WordPress Theme from DIYthemes. WordPress Admin

Potrebbero piacerti anche