how to print 2-D array using a single for loop?
Answers were Sorted based on User's Feedback
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 |
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 |
main() { clrscr(); } clrscr();
c program to subtract between two numbers without using '-' sign and subtract function.
what is a headerfile?and what will be a program without it explain nan example?
what is meant by c
How can a program be made to print the line number where an error occurs?
write an algorithm to get a sentence and reverse it in the following format: input : I am here opuput: Here Am I note: first letter of every word is capiatlised
What's a good way to check for "close enough" floating-point equality?
Difference between goto, long jmp() and setjmp()?
Illustrate it summing the series 2+4+6+......to n terms using (i) while loop (ii) do-while loop
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
How can I send mail from within a c program?
what is the difference between class and unio?