how to print 2-D array using a single for loop?
Answer Posted / 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 |
Post New Answer View All Answers
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
Explain how do you generate random numbers in c?
What does p mean in physics?
What are dangling pointers? How are dangling pointers different from memory leaks?
What is a spanning Tree?
What is the function of multilevel pointer in c?
What would be an example of a structure analogous to structure c?
Can you explain the four storage classes in C?
Write the syntax and purpose of a switch statement in C.
Write a program on swapping (100, 50)
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
What are header files and explain what are its uses in c programming?
Compare interpreters and compilers.
What is break in c?
code for replace tabs with equivalent number of blanks