how to print 2-D array using a single for loop?
Answers were Sorted based on User's Feedback
Answer / tknowledge05
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3]={2,4,5,7,2,9,2,3,2};
int f=0,i;
printf("\n");
for(i=0;f!=3;i++)
{
if(i==3)
{f++;
printf("\n");
i=0;
}
printf("%d ",a[f][i]);
}
getch();
}
Is This Answer Correct ? | 21 Yes | 4 No |
Answer / vinay joshi
void main()
{
int i,j=-1;
int a[3][2];
label:j++;
for(i=0;i<2;i++)
{
if(j>3)
{
//printf("%d",j);
break;
}
printf("enter the element:");
scanf("%d",&a[j][i]);
if(i==1 )
{
goto label;
}
}
j=-1;
label2:++j; printf("\n");
for(i=0;i<2;i++)
{
if(j>3)
{
break;
}
printf("%d\t",a[j][i]);
if(i==1)
{
goto label2;
}
}
getch();
}
Is This Answer Correct ? | 1 Yes | 4 No |
How the C program can be compiled?
Can a function argument have default value?
This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory
main() { char p[] = "hello world!"; p = "vector"; printf("%s",p); }
2 Answers Vector, Vector India,
what is differnence b/w macro & functions
What is a pragma?
Explain demand paging.
What is the difference between text files and binary files?
Explain the use of #pragma exit?
When should a type cast not be used?
11. Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555