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 is the significance of static storage class specifier?
how can i get the output 54321 4321 321 21 1 in c programming........???? pls help......
what is an ERP?
what is the difference b/w NULL and null?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
diff .between strcture and union
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What is a floating point in c?
Explain the meaning of keyword 'extern' in a function declaration.
What does %2f mean in c?
I have one doubt. What does below statement mean? #define sizeof(operator) where operator can be int or float etc. Does this statement meaningful and where it can be used?
what is a stack