Answer This? what would be output?
hello friend pls tel the output of this pro and als describe how?
#define ROWS 3
#define COLUMNS 4
int z[ROWS][COLUMNS]={1,2,3,4,5,6,7,8,9,10,11,12}
main()
{
int a,b,c;
for(a=0;a<ROWS;++a)
{
c=999;
for(b=0;b<COLUMNS;++b)
if(z[a][b]<c)
{
c=z[a][b];
}
printf("%d",c);
}
}
Re: Answer This? what would be output?
fhjoshngchkjmpgknm;,mn;fmgnp;lfm,ln,[;lgh,jnfnl,fl
Re: Answer This? what would be output?
1111111111111111111111111111111111111111111
Re: Answer This? what would be output?
[QUOTE=amar1_001;19870]hello friend pls tel the output of this pro and als describe how?
#define ROWS 3
#define COLUMNS 4
int z[ROWS][COLUMNS]={1,2,3,4,5,6,7,8,9,10,11,12}
main()
{
int a,b,c;
for(a=0;a<ROWS;++a)
{
c=999;
for(b=0;b<COLUMNS;++b)
if(z[a][b]<c)
{
c=z[a][b];
}
printf("%d",c);
}
}[/QUOTE]
123 i s the answer
Re: Answer This? what would be output?
[QUOTE=amar1_001;19870]hello friend pls tel the output of this pro and als describe how?
#define ROWS 3
#define COLUMNS 4
int z[ROWS][COLUMNS]={1,2,3,4,5,6,7,8,9,10,11,12}
main()
{
int a,b,c;
for(a=0;a<ROWS;++a)
{
c=999;
for(b=0;b<COLUMNS;++b)
if(z[a][b]<c)
{
c=z[a][b];
}
printf("%d",c);
}
}[/QUOTE]
press f7 for compilation you know the reason for printing
Re: Answer This? what would be output?
hi ,
this is maddy
the o/p of given prg is 1.
description: clearly defins the value of rows =3,colomn=4
hence the matrix z has the dimension Z[3][4]
after initialization the matrix is 1 2 3 4
5 6 7 8
9 10 11 12
now in first for loop a=1,c=999,second for loop b=1
so z[1][1]=1 and after checking condition z[1][1]<999
is true then c= z[1][1]=1
Re: Answer This? what would be output?
i cant understand give the program
Re: answer to thread problem
[QUOTE=manish_tech;20074]ans:1 5 9 is the correct answer[/QUOTE]
u r right this is the correct answer
Re: Answer This? what would be output?
The answer is 1 since the first element of the matrix is 1.
Re: Answer This? what would be output?
Re: Answer This? what would be output?
1 5 9 is the output.
z={1,2,3,4,
5,6,7,8,
9,10,11,12}
in the first row 1 is the smallest and in the second row 5 is the smallest and in the third row 9 is the smallest.
according to your program c will always hold the smallest value in all the rows therefore 159 is the output
Re: Answer This? what would be output?
the answer is 1 , 5 , 9
nice question
Re: Answer This? what would be output?
The answer is 1,3,9.
Array is of z[3][4] = { 1 2 3 4
5 6 7 8
9 10 11 12
};
First Row
----------
first iteration - z[0][0] < c
1 < 999
c=1
Next Iteration - z[0][1] < 1 False so c values remains same ie c=1
1 < 1
Next iteration - z[0][2] < 1 False so c values remains same ie c=1
Next Iteration - z[0][3] < 1 False so c values remains same ie c=1
So least value element is taken from first row.
Similarly for next two rows.
hence the output would be 1,5,9.