Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to print 2-D array using a single for loop?

Answers were Sorted based on User's Feedback



how to print 2-D array using a single for loop?..

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

how to print 2-D array using a single for loop?..

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

Post New Answer

More C Interview Questions

What is the difference between a structure and a union?

2 Answers  


What are the restrictions of a modulus operator?

0 Answers  


what is the difference between call by value and call by reference?

5 Answers   Genpact, Global Logic, Infosys,


Write a program or provide a pseudo code to flip the 2nd bit of the 32 bit number ! (Phone Screen)

1 Answers   NetApp, PTU, Wipro,


What is local and global variable in c?

0 Answers  


What will be the outcome of the following conditional statement if the value of variable s is 10?

0 Answers  


what are bitwise shift operators?

4 Answers  


What is null character in c?

1 Answers  


How to swap 3 numbers without using 4th variable?

5 Answers  


How does placing some code lines between the comment symbol help in debugging the code?

0 Answers  


without using control structures and control structures find the max and min of given 2 nos

1 Answers   HCL,


What is the best way to comment out a section of code that contains comments?

0 Answers  


Categories