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

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,


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

6 Answers   Fusion Systems GmbH,


main() { extern int i; i=20; printf("%d",i); }

1 Answers   Value Labs,


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


WAP to display 1,2,3,4,5........N

2 Answers  






what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

3 Answers   Wipro,


write a c-program to display the time using FOR loop

3 Answers   HCL,


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


#include<stdio.h> main() { register i=5; char j[]= "hello"; printf("%s %d",j,i); }

2 Answers  


What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

0 Answers  


What are segment and offset addresses?

2 Answers   Infosys,


main() { int i=10; i=!i>14; Printf ("i=%d",i); }

1 Answers  


Categories