Hsslive-xi-cs-KEY-dec-2024-menoup
Hsslive-xi-cs-KEY-dec-2024-menoup
ANSWER KEY
SUBJECT: COMPUTER SCIENCE
29. Briefly explain any three stream functions for I/O operations used in C++:
Answer:
get( ) - used to input a single character or stream of characters
Header file : iostream
Syntax : cin.get(variable) ; cin.get(array name , size) ;
Eg: cin.get(ch) ; // accepts a single character
getline( ) - used to input a string
Header file : iostream
Syntax : cin.getline(array name , len) ;
Eg : cin.getline(str,10);
put( ) - used to display a character
Header file : iostream
Syntax : cout.put(variable or character constant) ;
Eg : char ch='B' ;
cout.put(ch) ;
30. (a) Define the term operating system. Name any two of its functions:
Answer:
Operating system: Set of programs that act as an interface between the user and computer hardware.
Example:- DOS, Windows, Unix, Linux
Functions:
o Memory management.
o Process management
(b) Explain briefly different types of language processors:
Answer:
Assembler: Converts assembly language into machine language.
Interpreter: Converts a high level language program into machine language line by line.
Compiler: Converts the whole high level language program into machine language at a time.
31. (a) Write an algorithm to print the numbers from 1 to 100: (b) Draw its Flowchart:
Answer:
1. Start
2. N=1.
3. Repeat steps 4 and 5 until N<=100.
4. Print the value of N.
5. Increment N by 1.
6. Stop
3. Update statement: The update statement modifies the loop control variable by changing its value. The update
statement is executed before the next iteration. eg. i++
4. Body of the loop: The statements that need to be executed repeatedly constitute the body of the loop.
eg. cout<<i;
Exit-Controlled Loop
Entry-Controlled Loop
The condition is checked after executing the loop
The condition is checked before executing the loop body.
body.
for and while loops do-while loop
Executes at least once, even if the condition is false
May not execute if the condition is false initially.
initially.