AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: tmchow — October 6, 2006
    -13 votes
      + -

    20 assuming that the size of an int is 2

  2. Submitted By: octav_timofte — October 6, 2006
    +5 votes
      + -

    int (*a)[10]; represents the declaration of a pointer to an array of ten integers. So the value of a is initially some address allocated by the compiler and don’t rely on the fact the address is 0 as it happens for static variables.
    The value can be zero if you add the “static” keyword in front of declaration but I don’t advise you to further use this pointer to access some elements.

    If the integer is n bytes ( 2 or 4 depending on the language) it is true that the value of a will be increase with 10*n.

    Test this program to understand:

    #include <stdio.h>

    void main(int argc,char*argv[])
    {
    int b[10]={1,2,3,4};
    int (*a)[10];
    printf(”%pn”,a);
    printf(”%dn”,(*a)[0]);
    a++;
    printf(”%pn”,a);
    a=&b;
    printf(”%pn”,a);
    printf(”%dn”,(*a)[0]);
    }

  3. Submitted By: Tom — October 21, 2006
    -1 votes
      + -

    To octav_timofte:

    Just run your program under VC++ 2005 Express Edition, it showed me an error, “The variable ‘a’ is being used without being defined”.

    I am not sure what compiler you use, but I think int (*a)[10] only declares a pointer, not initialized. a++ is illegal.

    Correct me if not right.

  4. Submitted By: r_d — October 30, 2006
    +0 votes
      + -

    a++ is not illegal. It will just point to data out of
    array range. Using it to access data out of array range will be illegal.

  5. Submitted By: k3xji — February 13, 2007
    +0 votes
      + -

    If the expression has been:
    int *a[10];
    a++;
    Then this would be a 10 sized pointer-array to integers which are not defined yet.’a’ points to the first adress which holds a pointer to integer.When a++ executes the sizeof POINTER type will be added to a and this will point to the second element of the pointer-array.

    But the expression is:
    int (*a)[10];
    This expression is garbage.Compiler would not generate code for it.It is a function pointer which return int[10], so it is nonsense.Also following code is same:
    int (* a(float h))[10];

  6. Submitted By: DREAMER — October 16, 2007
    -1 votes
      + -

    I tested the following code in Microsoft Visual C++.

    int a[4] = {1, 2, 3, 4};
    a++;

    I got error that “++ need l-value”.

    Why is that?

  7. Submitted By: mc — October 16, 2007
    -2 votes
      + -

    It should be like *(a++)
    then, a[1] is the answer.

  8. Submitted By: RAJESH JNU — January 8, 2008
    +0 votes
      + -

    a++ will give the (address of a + 40)

  9. Submitted By: Talmeez ul Hassan — September 17, 2008
    +0 votes
      + -

    It will point to illeagal value. Because we cant grow an array dynamically. I it is leagal to use becoz compiler does not ruturn error. But logically it it incorrect.
    The newer version of C++ does not allow this declearation as it does not make any sense and is useless.

  10. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.