Midterms Flashcards

1
Q

group of statements that together perform a task

A

function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

tells the compiler about a function’s name, return type, and parameters

A

function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

already present inside the header file, included at the beginning of a program

A

library functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

we have tow write a body of a function and call the function when required

A

user-defined functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

why we need functions in c++

A
  • errors are easy to track
  • reduces size of code
    -replacing duplicate statements with function calls
  • reusability of code
  • improves code readability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

various forms of the main method

A

main()
main (void)
void main()
void main (void)
int main (int argc, charargv[])
void main(int argc, char
argv[])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

main method that does not return any value should have the return type?

A

void

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

main method that returns a value should have the return type?

A

int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

also called function prototype. specifies the name of a function to be used in the program like a variable declaration

A

function declaration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

syntax of function declaration

A

return_data_type function_name (data type arguments);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

means writing the body of a function, consisting of statements that perform specific tasks

A

function definition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

invoking a function also means

A

calling a function/function call

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

two methods to call a function

A
  1. call by value
  2. call by reference
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

copies the actual value of an argument into the formal parameter of the function

A

call by value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

function that is expanded in line when it is invoked thus saving time

A

inline function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Makes program execution faster because it saves the function location into the compile time

A

Inline function

17
Q

this is accessible by all the private and protected members of the class

A

friend function

18
Q

true or false: a friend function cannot be called using the object of the class as it is not in the scope of the class

A

true

19
Q

declares members that are not bound to class instances; shared by all objects of the class

A

static data members

20
Q
A
21
Q

why return 0?

A
  • represents the status of the program
  • a zero value indicates that the program is successful and a non-zero value indicates a problem in the program
  • the program execution will reach the return zero statement if the above statements executed successfully
22
Q

describe int main

A

int main is a declaration defining the main function. it returns an integer value to the operating system. the return value can be used to indicate the success or failure of the program (with 0 typically indicating success), which can be useful for debugging code.

23
Q

what is a main function?

A

main functions are the entry point of any program or the function that is called when the program is first launched.

24
Q

what is void main ()

A

void main() is a declaration of the main function that doesn’t return any value to the operating system. it is used when one doesn’t want to return any value to the main function. however, this is not the standard main method for programming; it is not recommended for use.

25
Q

what is int main (int argc, char**argv)?

A

this is also a main method that returns an integer value but takes two parameters: argc and argv. this is used for command-line prompting. the argc parameter represents the number of command-line arguments passed to the program, including the name of the program itself. meanwhile, argv, is an array of character pointers representing the actual command-line arguments.

26
Q

which main methods are standard-compliant?

A

int main() and int main (int argc, char argv[])

void main is not

27
Q

this is the ability to take more than one form

A

polymorphism

28
Q

this allows objects to have different internal structure to share the same external interface

A

polymorphism

29
Q

the number and type of arguments that a function may take is defined in the function itself

A

function overloading

30
Q

true or false: a function may take zero or more arguments when called

A

treu

31
Q

this is the function without its body

A

prototype of a function

32
Q

this declares the return type of the function that declares the number, the types and order of parameters the function expects to receive

A

function prototype