Thread: Can someone explain this question to me?

  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    28

    Can someone explain this question to me?

    Given the following function prototypes and variable declarations, which of the following is a syntactically correct function call which won't produce any warnings when compiled?
    Code:
    int func1(int a, int* b); 
    int func2(int a); 
    void func3(int a, int b); 
    int func4(int a, int b);
    Code:
    int a = 3, b = 8; 
    int* p = &b;


    The answer is 1 of the following:

    a = func1(p, &a);

    func3(&b, p);

    b = func2(a);

    func5(p, a, *p+4);

    I guess I am just confused as to how to lay this out in my IDE.

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    IDE's don't enter into it. You're supposed to answer it by looking at it. Look at each function call separately. How about this one:
    Code:
    func5(p, a, *p+4);
    With the given function prototypes, is this a valid function call?
    What about the others?
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Sep 2013
    Posts
    28
    Well just from looking it at I want to say the correct answer is b = func2(a);.

    The others involve data not in the prototype?



  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by pat4prez View Post
    Well just from looking it at I want to say the correct answer is b = func2(a);.

    The others involve data not in the prototype?


    What do you mean by "data not in the prototype"?

  5. #5
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by pat4prez View Post
    Well just from looking it at I want to say the correct answer is b = func2(a);.
    I agree!
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please explain me the question !!
    By rajarshi in forum C Programming
    Replies: 2
    Last Post: 11-13-2011, 11:35 PM
  2. c++ array question please explain
    By corbinc in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2009, 03:02 PM
  3. Assign. question, please explain
    By lesodk in forum C++ Programming
    Replies: 6
    Last Post: 05-17-2009, 08:53 AM
  4. can anyone explain this question for me?
    By MyRedz in forum C++ Programming
    Replies: 4
    Last Post: 02-05-2009, 06:30 AM
  5. C question explain please..
    By code_guru in forum C Programming
    Replies: 3
    Last Post: 11-04-2005, 02:54 AM