Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
C C++ HR Java
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.
* *
* * * * * * * * *
* * *
* * * * *
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;
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
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
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;
* * *
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
* /*
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
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(" ");
} 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");
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
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; } }
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
* * * *
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.
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
Enter your
interview mantra
en_US
Get Shareaholic
About the Author: This post was written by Utsav Banerjee. You can reach Utsav on email at fugitiveland@gmail.com
interview mantra
en_US
Subscribe
Bottom of Form
Like Dislike
Share No thanks
Post as Image
Snehalvjadhav 2 comments collapsed Collapse Expand tell me the code of following pattern. * * * * * * * * *
#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>
how can i print '**'s four sides of screen???? example like this............ *********************************************************************** * * * * * * * * * * * * * * * * * * * * * *********************************************************************** ** can any 1 help me??????please.......
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...........
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++; }
");}
0 Like Jayesh5101992sapkale 1 comment collapsed Collapse Expand Remove all last line from it
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>
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>
0 Like
Jayesh5101992sapkale 1 comment collapsed Collapse Expand sorry this is not suitable.,,,,I will provide in to parts
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("*"); }
0 Like abc 2 comments collapsed Collapse Expand give me the code of following pattern *
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++; } }
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
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>
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(); }
vidhya 1 comment collapsed Collapse Expand can u tell me how to put tis pattern * *** ***** *** *
abc 1 comment collapsed Collapse Expand give me the code of following pattern 1 11 121 1331 14641
ATUBH BHAWARE 2 comments collapsed Collapse Expand plz someone tell me program for following output ** **** ****** ******** ********** ******** ****** **** **
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>
supantha kumar pal 4 comments collapsed Collapse Expand plz tell the code.... 1 23 456 7 8 9 10
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>
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>
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>
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 * * ******
R.Mahalakshmi 2 comments collapsed Collapse Expand i need simple c program to print like a following pattern * *** *****
*** *
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(); } } }
0 Like
jasleen 1 comment collapsed Collapse Expand can u please give me a coding of this pattern? * ** ** *******
jyotish 1 comment collapsed Collapse Expand plz someone tell me program for following output abcdedcba abcd dcba abc cba ab ab aa
ATUBH BHAWARE 1 comment collapsed Collapse Expand plz someone tell me program for following output * ** ***
*****
saurabh chopra 1 comment collapsed Collapse Expand sir,How can we print stars in a circle?
plz help mi to write ths pattern program.. ***************** ** ** ****** ****** 1** ** **** **** ** ***********
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)
* ********** ********** * ** ********* ********* ** *** ******** ******** *** **** ******* ******* **** ***** ****** ****** ***** ****** ***** ***** ****** ******* **** **** ******* ******** *** *** ******** ********* ** ** ********* ********** * * **********
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
456 7 8 9 10
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>
0 Like sridhar 1 comment collapsed Collapse Expand The credit of this post goes to Utsav Banerjee.. Good work Utsav! Editor, Interview Mantra
Ridzi0207 1 comment collapsed Collapse Expand plz tell me the code for ******* ******* *** * *** *******
* **** *
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
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>
0 Like Ajay 1 comment collapsed Collapse Expand please giv me the code for following pattern! 1 11 21 1211 111221
312211 13112221
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.
0 Like Grissar 1 comment collapsed Collapse Expand The drawing didn't come out ok. So, here's a photo.
0 Like
deepak singla 1 comment collapsed Collapse Expand give me the code of following pattern 1 01 101 0101 10101
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
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
0 Like KALE SOMNAH 3 comments collapsed Collapse Expand PLS tell me code to wether the given strig s palioderm or not
A Like
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");
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>
0 Like ankur loved 1 comment collapsed Collapse Expand this is not the optimized code this will use more memory
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(); } } }
#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>
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"); }
0 Like loveneesh 1 comment collapsed Collapse Expand how can i print the pattern ***** **** *** ** *
0 Like
Vjy 1 comment collapsed Collapse Expand 1 141 13531 1357531 13531 141 1
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!!!!!!!!
0 Like sushant choudhary 1 comment collapsed Collapse Expand code to print the following pattern: 1 131 13531 1357531 13531 131 1
A Like
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.
0 Like jasleen 1 comment collapsed Collapse Expand can u please give me a coding of this pattern? *
0 Like saurabh 1 comment collapsed Collapse Expand heloo friends your mind is very sharp becouse your programing is very dilicious
0 Like amit sisodiaa 1 comment collapsed Collapse Expand this is so goood for begainer
0 Like accesscode 2 comments collapsed Collapse Expand ***** **** *** ** * Try this>>>>>
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("*"); }
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
0 Like nitesh 1 comment collapsed Collapse Expand this is the best for bigners
0 Like Ashu 1 comment collapsed Collapse Expand thanks . this is very helpful
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 * ** *** **** ***** **** *** ** * */
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...;)
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; }
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; }
0 Like
supantha kumar pal 2 comments collapsed Collapse Expand plz tell me of this code.. 1 12 123 1234 12345
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(); }
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
0 Like preethi 1 comment collapsed Collapse Expand tell me the code for a aa aaa
aaaa aaaaa
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; }
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........... ** ** ** ** ** ***********
#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;}
0 Like manali 1 comment collapsed Collapse Expand plz tell me how to print the following pattern? ****** ***** **** *** ** *
0 Like
shahnawaz 3 comments collapsed Collapse Expand plz help me to write this program 54321 5432 543 54 5
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
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");
0 Like cliff 1 comment collapsed Collapse Expand please help me with code that displays characters in form of asteriks eg L ** ** ** ** ***********
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"); } }
0 Like
tejas chachad 1 comment collapsed Collapse Expand hey i want to print ****** ** ** ** ******
0 Like rajani jha 1 comment collapsed Collapse Expand i want the hint for the program ********* ******** ****** **** ** **** ****** ******** *********
0 Like
0 Like
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
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
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
programs performance review placement pointers programming quiz resume templates Resume
Recent Comments
Raavi Swami on C Interview Programs to print number patterns
anil
Rupinder32bhinder or not
Yogeshsudrik AMDOCS
Physics Prakash
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