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
What is class and object in c?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
What kind of structure is a house?
what type of questions arrive in interview over c programming?
Which are low level languages?
What are the 4 types of unions?
What are c identifiers?
How reliable are floating-point comparisons?
What is c mainly used for?
What is the use of pragma in embedded c?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
How can I get the current date or time of day in a c program?
What is the difference between procedural and functional programming?
Are pointers integers in c?
How can I read/write structures from/to data files?