C++ Programs Asked in Interview for Freshers - 2

Question: 6

What is file scope?

A variable declared all blocks and functions (precisely main ()) has the scope of a file.

The scope of a file scope variable is the entire program. The life time of a file scope variable is the life time of a program.

Question: 7

How many types of variable scopes are there? What are they?

Scope refers to the accessibility of a variable. There are four types of scopes in C++. They are:

Local scope, File scope and

Function scope, Class scope.

Question: 8

What is meant by void function?

The functions that return no value are declared as void. The data type of a function is treated as int, if no data type is explicitly mentioned.

Question: 9

What is the use of parameters passing in function?

The call statement communicates with the function through arguments or parameters.

Parameters are the channels through which data flows from call statement to function and vice versa.

Question: 10

Write the general syntax of a function prototype. Give an example.

The general syntax of a function prototype

<type > <function identifier> <arguments>;

For example:

Void fun (char);

Int max (int, int);

Int max (int a, int b);

Related Questions