Home / General Knowledge / Testing New :: Discussion

Discussion :: Testing New

  1. Determine Output:

    void main()

    {

    int a[] = {10,20,30,40,50}, j, *p;

    for(j=0; j<5; j++){

    printf("%d" ,*a);

    a++;

    }

    p = a;

    for(j=0; j<5; j++){

    printf("%d" ,*p);

    p++;

    }

    }

  2. A.

     10 20 30 40 50 10 20 30 40 50

    B.

     10 20 30 40 50 Garbage Value

    C.

     Error

    D.

     None of These

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Compiler error: lvalue required
    Error is in line with statement a++. The operand must be an lvalue and may be of any of scalar type for any operator, array name only when subscripted is an lvalue. Simply array name is a non-modifiable lvalue.


Be The First To Comment