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?

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


Please Help Members By Posting Answers For Below Questions

What is a scope resolution operator in c?

1223


What does it mean when a pointer is used in an if statement?

1074


Is there any demerits of using pointer?

1034


How are 16- and 32-bit numbers stored?

1259


Why is c not oop?

947


Where static variables are stored in c?

1067


Is c call by value?

983


How many levels deep can include files be nested?

1115


Explain what is operator promotion?

1046


Tell us two differences between new () and malloc ()?

1143


What is getche() function?

1003


What is a lookup table in c?

1067


What is #line in c?

983


Explain what standard functions are available to manipulate strings?

1043


What are volatile variables in c?

905