Write a program to print a square of size 5 by using the
character S.
Answers were Sorted based on User's Feedback
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 ? | 36 Yes | 10 No |
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 |
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 |
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 |
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 |
How to use power function under linux environment.eg : for(i=1;i<=n;i++){ pow(-1,i-1)} since it alerts undefined reference to 'pow'.
main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }
main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }
main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?
Give a oneline C expression to test whether a number is a power of 2?
25 Answers EA Electronic Arts, Google, Motorola,
Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).
13 Answers Intel, Microsoft, TCS,
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); }
How can you relate the function with the structure? Explain with an appropriate example.
Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange
write a c program to print magic square of order n when n>3 and n is odd?
Print an integer using only putchar. Try doing it without using extra storage.
what is oop?