Which of the following are valid function prototypes?
x one(int a, int b);
int thisone(char x);
char another(int a, b);
double yetanother;
void thelastone();
void (function1) void;
void function2(void)
void function3(n, x, a, b);
x void finction4(int n, float, char c);
x void function5(int, a, int n);

Which of the following lines contain errors?
int a, b(2);
x float a23b[99], 1xy[66];
void city[36], town[45];
double temperature[-100];
long phone[200];
int a = {11,22}, b[33];
float c[3] = {11,22,33,44};
double d(4) = (11,22,33,44);
d[4] = {11,22,33,44};
x int a[3]/11,22,33/;

Given this function prototype int calc_area(int*, int*); and
the following variable declarations ( int height, width, area ),
Which of the following lines contain errors?
x clac_are(height, width);
calc_area(*height, *width);
calc_area(&height, &width);
x area = calc_area(&width, &height);
area = &height * &width;

Which of the following lines contain errors?
delete myArray;
x new [8];
new double[8];
delete [10] myArray;
new[1] = 3;

I'm doing questions in back of a book but there are no answers to check work!Need help to make sure I'm correct and x's are my answers!

5 Years
Discussion Span
Last Post by NathanOliver

look be side question it has an x beside it on left side like x one(int a, int b);

Edited by newbee234: n/a


Well you have some wrong on every question. First can I suggest you use code tags when posting code so that it is easier to read. Question 1 ask about functions. A function is formed like

return_type Function_name(variable_type name(optional))

A function does not need to actually name the variable if it is a prototype but it does need to have the variable type.

Question 2 deals with variable naming, initializing and arrays. Can an array have a negative subscript? What does double d(4); mean?

here is a good link for learning functions.

and here you can learn up on variables


this website did not help for what I understand the one (int a, int b) only is valid!


is void thelastone(); a proper function prototype? If not why?

so void can be a proper function if so then

one(int a, int b);
int thisone(char x);
void thelastone();
void function3(n, x, a, b);
void finction4(int n, float, char c); are the correct answers


What are the types for

void function3(n, x, a, b);



one(int a, int b);

have a return type?

for what I understand that the

int a, int b

is the return type


n, x, a, b

is also as long as it is stated to be returned


int one(int a, int b)
if (a > b)
return a;
return b;

Edited by newbee234: add


The return type does not come from the parameter list. To qualify as correct a function prototype you need to have have three things. You need a return type, a correct name for the function and you need to have a parameter list. The parameter list need not have any parameters but you still need the () after the name to make it a function. You also do not need to name any of the parameters in the parameters list but you do need the type specified.

// the are all correct
int foo();
void foo(int);
double add(double first, double second);
void print(void);  // okay (void) means I have no parameters

// these are all incorrect
foo();  // no return type
void foo(a);  // type of a is not specified
int 2add(int, int);  // bad name
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.