Thread: Tutorial Quizzes

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    15

    Exclamation Tutorial Quizzes

    Ok, I feel even stupider then I did before I am stuck on the quiz for lesson 4 tutorial:

    1. Which is not a proper prototype?
    A. int funct(char x, char y);
    B. double funct(char x)
    C. void funct();
    D. char x();

    2. What is the return type of the function with prototype: "int func(char x, float v, double t);"
    A. char
    B. int
    C. float
    D. double
    3. Which of the following is a valid function call (assuming the function exists)?
    A. funct;
    B. funct x, y;
    C. funct();
    D. int funct();

    4. Which of the following is a complete function?
    A. int funct();
    B. int funct(int x) {return x=x+1;}
    C. void funct(int) {cout<<"Hello"}
    D. void funct(x) {cout<<"Hello"}

    The ones that are bold I am confused on. The answer to number one is B and the answer to 3 is C. But Why!? Why isn't one's answer D? I thought if you had nothing in the parenthesis then you had to have void!? And for number three, I'm just confused! Please help me I can't go on knowing I don't know something

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    For #1, there is a semi-colon missing at the end of the line. For #3, A and B are both missing parentheses, and D is a function prototype.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    Now im a novie, so some may be wrong, im just takin a crackshot at these hehe.

    1.B
    >>no semi colon. ";"

    3.C
    >> to call a function from within another function, classes, ect. You must have ()'s included. Here is why i think the other answers are wrong.
    A: no parentheses. *edit* i said parameters when you dont infact need them, misleading answer hehe.
    B: no parentheses.
    D: no need to declare the functions data type (by using "int" befor the function name) because a functions definition (and possibly prototype) already tells you what its data type is. Or return type, whatever you wanna call it lol.

    I may be wrong, but i just decided to take a whack at it, gl
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  4. #4
    Registered User ~Kyo~'s Avatar
    Join Date
    Jun 2004
    Posts
    320
    1. Which is not a proper prototype?
    A. int funct(char x, char y);
    B. double funct(char x)
    C. void funct();
    D. char x();

    It's B because there is no semicolon =p. As for D you don't need to have a void in there not in C++ at least. Its just a function called x that returns a char and has no parameters.

    3. Which of the following is a valid function call (assuming the function exists)?
    A. funct;
    B. funct x, y;
    C. funct();
    D. int funct();

    its C beause
    A and B are missing ()'s.
    D has int before it this is not a proper call.
    C is the only function that would not generate an error

  5. #5
    Registered User
    Join Date
    Oct 2004
    Posts
    15

    Talking

    I feel stupid lol

    Thanx Guys

  6. #6
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Don't be, we've all been there, and understanding comes with experience and practice.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My new website
    By joeprogrammer in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 03-17-2006, 07:38 PM
  2. Cprog tutorial: Design Patterns
    By maes in forum C++ Programming
    Replies: 7
    Last Post: 10-11-2004, 01:41 AM
  3. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  4. Problem with tutorial (Vector class)
    By OdyTHeBear in forum C++ Programming
    Replies: 4
    Last Post: 12-18-2002, 02:49 PM
  5. My DirectInput tutorial....
    By jdinger in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-18-2002, 11:32 PM