Tuesday, 21 August 2018

CBSE Class 12 - Computer Science - C++ Standard Headers - Questions and Answers (#cbsenotes)(#eduvictors)

 C++ Standard Headers

(Q & A)

CBSE Class 12 - Computer Science - C++ Standard Headers - Questions and Answers (#cbsenotes)(#eduvictors)

Q1: What is the purpose of a header file in a program?

Answer: Header files provide function prototypes, definitions of library functions, declaration of data types and constants used
with the library functions.

Q2: What is the purpose of the following header files?
a) iostream.h b) stdio.h c) ctype.h
d) string.h e) math.h f) stdlib.h

iostream.h: Defines stream classes for input/output streams
stdio.h  : Standard input and output
ctype.h  : Character tests
string.h : String operations
math.h   : Mathematical functions such as sin() and cos()
stdlib.h : Utility functions such as malloc() and rand()

Q3: Which statement is used to call headers file ain a C++ program?

Answer: #include statement. For example #include <stdio.h>
An include statement that tells the compiler to put code from the header file called stdio.h into our program before creating the executable.

Q4: State the purpose of the following functions?

isalpha(c) - check whether the argument is alphabetic or not.
islower(c) - check whether the argument is lowercase or not.
isupper(c) - check whether the argument is uppercase or not.
isdigit(c) - check whether the argument is digit or not.
isalnum(c) - check whether the argument is alphanumeric or not.
tolower() - converts argument in lowercase if its argument is a letter.
toupper(c) - converts argument in uppercase if its argument is a letter.
strcat() - concatenates two string.
strcmp() - compare two string.
pow(x,y)- return x raised to power y.
sqrt(x)- return square root of x.
random(num)-return a random number between 0 and (num-1)
randomize- initializes the random number generator with a random value.

Q5: How do you get access to the string data type?

Answer: By including the string header file i.e. #include <string.h>

Q6: What can happen if you include a header file multiple times?

Answer: It will raise errors about multiple declarations.

Q7: What is the difference between randomize() and rand()?

randomize() : This function provides the seed value and an algorithm to help random( ) function in generating random numbers. The seed value may be taken from current system’s time.

rand(<int>) : This function accepts an integer parameter say x and then generates a random value between 0 to x-1. 
For example, rand(7) will generate numbers between 0 to 6.

Q8: Which C++ header file (s) will be included to run /execute the following C++ code?

void main( )
int Last =26.5698742658;

Answer: iostream.h, iomanip.h

Q9: Jayaprada has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

void main()
float A, Number, Outcome;

(a) iostream.h OR iomanip.h
(b) math.h

No comments:

Post a Comment

We love to hear your thoughts about this post!