HI,
I am sort of newbie so I cant figure out whats going wrong in this code.
Objective: To print a square box made out of 'S' i.e. S's are printed as outline of the square.
the Square has arm length of 5 and the code has been compiled using Devcpp IDE 4.9.9.2 .
It says no error while compiling but on running this it says .exe has stopped working.Same fate it met on turbo C also. There it says abnormal termination of application.
Here is the code:
Code:
#include<stdio.h>
main()
{
int i, j, x;
x = 'S';
for (i=0; i<5; i++) {
for(j=0; j<5; j++) {
if (i == 0 || i == 4)
{
printf("%s", x);
}
if (i == 1|| i == 2|| i == 3)
{
if ( j == 0 || j == 4)
{
printf("%s", x);
} else {
printf("\0");
}
}
if ( j == 4 && i !=4 )
{
printf("\n");
}
}
}
return(0);
}
Also tell the proper position to use clrscr() and getch() in this code.