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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe the difference between = and == symbols in c programming?

782


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

587


I need previous papers of CSC.......plz help out by posting them.......

1820


What is the difference between fread and fwrite function?

642


What is #define used for in c?

618






What functions are used in dynamic memory allocation in c?

601


hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm

1637


What is the explanation for modular programming?

691


How do you define CONSTANT in C?

659


Explain data types & how many data types supported by c?

588


What is the data segment that is followed by c?

619


Explain how to reverse singly link list.

616


What is the g value paradox?

650


What is c system32 taskhostw exe?

598


Explain the use of keyword 'register' with respect to variables.

594