I am a beginner in C++ and am creating a program in which I want to create a frame with a border using the character "#". The code I have written is as follows: #include<stdio.h> #include<conio.h> void main() { clrscr(); int xc; //xc is the x-coordinate of the cursor for(xc=0;xc<40;xc++) gotoxy(xc,20); printf("#"); getch(); } But the program executes only with a single # on the screen.
Because your printf statement is outside of the loop as you have no curly braces and so only the nest statement is what is considered as looping statement.
Thankyou shabbir.I actually wanted to print this: Code: ********** * * * * * * * * * * * * * * * * ********** I got the code for the upper and lower lines but when I try to change the y-coordinate for the same using the above code,it gives output as follows: ********** *******<20 stars>******* Please tell me how to proceed and do I need to replace the cursor somewhere to get it correct?