Write a program to print a square of size 5 by using the
character S.

Answers were Sorted based on User's Feedback



Write a program to print a square of size 5 by using the character S...

Answer / gaurav_jain

/* I am using more brackets which can be ignore. */
#include<stdio.h>
main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(i==0 || i==4)
{
printf("S");
}
else if(j==0 || j==4)
{
printf("S");
}
else
{
printf(" ");
}
}
printf("\n");
}
}

Is This Answer Correct ?    35 Yes 9 No

Write a program to print a square of size 5 by using the character S...

Answer / chand

main()
{
for(int i=0;i<5;i++)
{
printf("\n");
if(i==0||i==4)
{
for(int j=0;j<5;j++)
printf("S");
}
else
printf("S S");
}

Is This Answer Correct ?    19 Yes 10 No

Write a program to print a square of size 5 by using the character S...

Answer / riz

#include<stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("S");
}
printf("\n");
}
}

Is This Answer Correct ?    15 Yes 10 No

Write a program to print a square of size 5 by using the character S...

Answer / nagraj

main()
{
for(int i=0;i<5;i++)
{
printf("\n");
if(i==0||i==4)
{
for(int j=0;j<5;j++)
printf("S");
}
else
printf("S S");
}

Is This Answer Correct ?    8 Yes 8 No

Write a program to print a square of size 5 by using the character S...

Answer / aditti saxena

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
n=5;
printf("\n\n");
for(i=1;i<=n;i++)
printf("s ");
printf("\n\n");
for(i=1;i<=n-2;i++)
{
printf("s ");
for(j=1;j<=n-2;j++)
printf(" ");
printf("s\n\n");
}
for(i=1;i<=n;i++)
printf("s ");
printf("\n");
getch();
}

Is This Answer Correct ?    3 Yes 3 No

Write a program to print a square of size 5 by using the character S...

Answer / kiran

#include<stdio.h>

int main()
{
int i,j;
for(i=0;i<5;i++)
{
printf("
");
printf("
");
for(j=0;j<5;j++)
{

if(i==0 || j==0 || i==4 ||j==4 )

printf(" S ");
else
printf(" ");
}
}
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Code Interview Questions

#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }

0 Answers  


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.

6 Answers   Fusion Systems GmbH,


What are segment and offset addresses?

2 Answers   Infosys,


plz send me all data structure related programs

2 Answers  


write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).

0 Answers   CDAC, College School Exams Tests,






programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h

1 Answers  


Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

1 Answers  


4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }

2 Answers   Broadridge,


How do you write a program which produces its own source code as its output?

7 Answers  


main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }

1 Answers   TCS,


{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

4 Answers  


int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,


Categories