Part I TrueFalse Global variables are preferable to local v

Part I - True/False

Global variables are preferable to local variables.

A function created with the int keyword at the beginning of its header is a function that returns a whole number.

A semicolon must be placed at the end of a function’s header.

Functions can and should be reused when possible.

When a sequential-access data file is opened for output, the value on the very first line of that file will be the first record that is read from the file.

A single file pointer such as outfile can perform both input and output to a sequential-access data file at the same time without closing and reopening the file.

The scope of a local variable is larger than the scope of a global variable.

We studied a built-in square library function to square a number.

A function may have no parameters passed to it.

A text file created with Notepad could be used as a sequential-access data file.

Solution

1. Global variables are preferable to local variables- False,

Reason- They are liable to cause bugs and waste memory. If you declare a global variable it will continue to use memory whilst a program is running even if you no longer need/use it.

2. A function created with the int keyword at the beginning of its header is a function that returns a whole number. False

Reason:- It can returned negative integers also. It will return whole number only if the returned type is signed int.

3. A semicolon must be placed at the end of a function’s header. False

4. Functions can and should be reused when possible.True

Reason:- We should reuse the function to avoid redundancy of same set of code in our solution. This will make code light wieght and also it will increase the quality of code.

5. When a sequential-access data file is opened for output, the value on the very first line of that file will be the first record that is read from the file. True, If we will rerun the program the same line will be appended again.

6. A single file pointer such as outfile can perform both input and output to a sequential-access data file at the same time without closing and reopening the file. True

Reason:- We have to create and object of fstream in order to read and write a file and dispose the object once all the file operation id done.

7. The scope of a local variable is larger than the scope of a global variable. False

Reason:- A global variable is available for use throughout your entire program after its declaration and local variables are not known to functions outside their own.

8. We studied a built-in square library function to square a number. True

Reason:-


9. A function may have no parameters passed to it. True

10. A text file created with Notepad could be used as a sequential-access data file. True

Function and its argument(s) Library Purpose
sqrt(x) x must be double math.h calculates the square root of x
Part I - True/False Global variables are preferable to local variables. A function created with the int keyword at the beginning of its header is a function tha
Part I - True/False Global variables are preferable to local variables. A function created with the int keyword at the beginning of its header is a function tha

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site