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 |
What are the disadvantages of c language?
what is linkage error when it occurs in c program
What are header files in c programming?
Explain argument and its types.
what is the basis for selection of arrays or pointers as data structure in a program
How can I rethow can I return a sequence of random numbers which dont repeat at all?
write a c program for greatest of three numbers without using if statment
What are the advantages of using Unions?
code for find determinent of amatrix
What is the difference b/w Structure & Union?
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
Explain what is the purpose of "extern" keyword in a function declaration?