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

Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1492


Explain how do you generate random numbers in c?

1077


What does p mean in physics?

1034


What are dangling pointers? How are dangling pointers different from memory leaks?

1294


What is a spanning Tree?

1575


What is the function of multilevel pointer in c?

1077


What would be an example of a structure analogous to structure c?

989


Can you explain the four storage classes in C?

1119


Write the syntax and purpose of a switch statement in C.

1095


Write a program on swapping (100, 50)

1113


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

1004


What are header files and explain what are its uses in c programming?

1119


Compare interpreters and compilers.

1061


What is break in c?

1022


code for replace tabs with equivalent number of blanks

2150