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 are the types of c language?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
Is main is user defined function?
Is there a built-in function in C that can be used for sorting data?
praagnovation
Do you know the difference between malloc() and calloc() function?
What functions are in conio h?
What does return 1 means in c?
How do I get a null pointer in my programs?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
What is pointer to pointer in c with example?
What are global variables and how do you declare them?
How can I send mail from within a c program?