Results 1 to 14 of 14

Thread: Answer This? what would be output?

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Answers
    28

    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);
    }
    }


  2. #2
    Junior Member
    Join Date
    Jul 2007
    Answers
    3

    Re: Answer This? what would be output?

    fhjoshngchkjmpgknm;,mn;fmgnp;lfm,ln,[;lgh,jnfnl,fl

    Last edited by manish_tech; 10-24-2007 at 01:36 AM.

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Answers
    3

    Re: Answer This? what would be output?

    1111111111111111111111111111111111111111111

    Last edited by manish_tech; 10-24-2007 at 01:38 AM. Reason: no ques at this moment

  4. #4
    Contributing Member
    Join Date
    Oct 2007
    Answers
    88

    Smile Re: Answer This? what would be output?

    Quote Originally Posted by amar1_001 View Post
    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);
    }
    }
    123 i s the answer


  5. #5
    Junior Member
    Join Date
    Jul 2007
    Answers
    3

    Cool answer to thread problem

    Quote Originally Posted by amar1_001 View Post
    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);
    }
    }
    ans:1 5 9 is the correct answer


  6. #6
    Contributing Member
    Join Date
    Oct 2007
    Answers
    88

    Smile Re: Answer This? what would be output?

    Quote Originally Posted by amar1_001 View Post
    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);
    }
    }
    press f7 for compilation you know the reason for printing


  7. #7
    Junior Member
    Join Date
    Oct 2007
    Answers
    3

    Red face 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


  8. #8
    Contributing Member
    Join Date
    Oct 2007
    Answers
    88

    Re: Answer This? what would be output?

    i cant understand give the program


  9. #9
    Junior Member
    Join Date
    Oct 2007
    Answers
    3

    Cool Re: answer to thread problem

    Quote Originally Posted by manish_tech View Post
    ans:1 5 9 is the correct answer
    u r right this is the correct answer


  10. #10
    Junior Member
    Join Date
    Nov 2007
    Answers
    2

    Re: Answer This? what would be output?

    The answer is 1 since the first element of the matrix is 1.


  11. #11
    Junior Member
    Join Date
    Nov 2007
    Answers
    2

    Re: Answer This? what would be output?

    123 is the answer


  12. #12
    Junior Member
    Join Date
    Oct 2007
    Answers
    4

    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

    Last edited by r.praveenkumar; 11-19-2007 at 03:09 AM.

  13. #13
    Junior Member
    Join Date
    Nov 2007
    Answers
    2

    Re: Answer This? what would be output?

    the answer is 1 , 5 , 9

    nice question


  14. #14
    Contributing Member
    Join Date
    Apr 2007
    Answers
    41

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact