C++ Interview Questions & Answers part 5

0
383
Q: – When I divide 5/3, I get 1. What is going wrong?

If you divide one integer by another, you get an integer as a result.

Q: – Are negative numbers true or false?

True

Q: – What is a Function?

A function is, in effect, a subprogram that can act on data and return a value. Every C++ program has at least one function— main(). When your program starts, main() is called automatically. main() might call other functions, some of which might call still others.

Q: – Why use unnecessary parentheses when precedence will determine which operators are acted on first?

A Although it is true that the compiler will know the precedence and that a programmer can look up the precedence order, code that is easy to understand is easier to maintain. .

Q: – Define Global Variables?

Variables defined outside of any function have global scope and thus are available from any function in the program, including main().

Q: – What effect do tabs, spaces, and newline characters have on the program?

Tabs, spaces, and newline characters (known as whitespace) have no effect on the program, although judicious use of whitespace can make the program easier to read.

Submitted By:-Ankur Goyal            Email-ID: – goyal.ankur30@yahoo.in

SHARE

LEAVE A REPLY