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 |
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.
{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above
func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }
void main() { int x,y=2,z; z=(z*=2)+(x=y=z); printf("%d",z); }
void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } } a. 5, 4, 3, 2, 1 b. 0, 1, 2, 3, 4 c. 0, 1, 2, 4, 8 d. 1, 2, 4, 8, 16
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024
#include<stdio.h> void fun(int); int main() { int a; a=3; fun(a); printf("\n"); return 0; } void fun(int i) { if(n>0) { fun(--n); printf("%d",n); fun(--n); } } the answer is 0 1 2 0..someone explain how the code is executed..?