CBSE Class 11 C++ Sample Paper-3 - GeeksforGeeks

23 Oct, 2018
Class- XI [Computer Science]Time Duration: 3 HrsM. M. 70General instructions:(i) All questions are compulsory(ii) Programming language : C++
SECTION A
1. Explain any 2 important features of an Operating System. 2There are various features of an Operating System. These are:
Memory Management
File Management
Hardware Interdependence
Process Management
Graphical User Interface
Networking Capability.
Memory Management: Memory management is the functionality of an operating system which handles or manages primary memory and moves processes back and forth between main memory and disk during execution.
File Management : Operating System helps to create new files in computer system and placing them at the specific locations. It helps in easily and quickly locating these files in computer system. It makes the process of sharing of the files among different users very easy and user friendly.
2. What is the difference between GUI and CUI? 2A GUI (Graphic User Interface) is a graphical representation in which the users can interact with software or devices through graphical icons.A CLI (Command Line Interface) is a console or text based representation in which the user types the commands to operate the software or devices.
3. What is the difference between copying and moving a file. 2Copy is to make a copy of the selected file or folder and place the duplicate in another drive or folder, while move is to move the original files from one place to another location. The move command deletes the original files, while copy retains them.
SECTION B
1. Explain the following terms with an example of each. (2 marks each)a. Comments : In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. Comments are statements that are not executed by the compiler and interpreter.In C/C++ there are two types of comments :Single line commentMulti-line commentRefer: Comments in C++
b. IdentifiersIdentifiers are used as the general terminology for naming of variables, functions and arrays. These are user defined names consisting of arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as a first character. Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers; they are reserved for special use. Once declared, you can use the identifier in later program statements to refer to the associated value. A special kind of identifier, called a statement label, can be used in goto statements.Refer: C++ Tokens
2. What do you mean by Programming Errors? Explain all types of errors. 3Error is an illegal operation performed by the user which results in abnormal working of the program.Type of errors :
Syntax errors : Errors that occur when the rules of writing C/C++ syntax are violated are known as syntax errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by compiler and thus are known as compile-time errors.
Run-time Errors : Errors which occur during program execution(run-time) after successful compilation are called run-time errors. Example: Division by zero error.
Logical Errors : On compilation and execution of a program, desired output is not obtained when certain input values are given. These types of errors which provide incorrect output but appears to be error free are called logical errors.
Refer: Errors in C++
3. Explain the term LIVEWARE. 1The programmers, systems analysts, operating staff, and other personnel working in a computer system or the organisation related to a computing environment is termed as Liveware.
SECTION C
1. Write a program to read a number from user and check whether the given no. is prime. 5You may Refer : Check if a number is prime or not
// C++ program to check if a// number is prime  #include <iostream>using namespace std;  int checkprime(int n){    ;    int i, flag = 1;    // Iterate from 2 to n/2    for (i = 2; i <= n / 2; i++) {        // If n is divisible by any number between        // 2 and n/2, it is not prime          if (n % i == 0) {            flag = 0;            break;        }    }      if (flag == 1)        cout << "prime number";      else        cout << "not a prime number";      return 0;}  int main(){    int n;    // Ask user for input      cout << "Enter a number: \n";      // Store input number in a variable    cin >> n;    checkprime(n);    return 0;}
2. Write a function to calculate the following series: 1 + X / X2 + 2X / X3+ 3X / X4 +................. + NX / XN+1
// C++ program to find sum of series// 1 + X / X<sup>2</sup>//+ 2X / X<sup>3</sup>+ ...... + NX / X<sup>N+1#include <iostream>#include <math.h>using namespace std;  double sum(int x, int n){    double i, total = 1.0;    for (i = 1; i <= n; i++)        total = total + (i * x / pow(x, i + 1));    return total;}  // Driver codeint main(){    int x, n;    cout << "enter the value of x \n";    cin >> x;    cout << "enter the number of terms \n";    cin >> n;    cout << "sum of series is:" << sum(x, n);    return 0;}
3. Evaluate the following C++ expressions where a, b, c are integers and d, f are floating point numbers. The Value of a = 6, b = 2, d = 1.5 (2 marks each)a) f = a + b/aOutput: 6b) c = ( a++) * d + bOutput: 8.5c) c = a – ( b++ ) * (–a)Output: -5
4. Find out the errors, underline them and correct them 4
Void main(){    int a, b = 2;    cout >> “Enter a Value                    cin                << “a”;    floating f = a / b;    if (a = < b)        cout << a <<” Greatest “;    else        cout << b << “ Greatest”;    cout <<”Values of f is : “<< f;    f + = 13;    cout << Now Value of f is << f;}
Correct code:
#include <iostream.h>void main(){    int a, b = 2;    cout << “Enter a Value”;    cin >> a;    float f = a / b;    if (a <= b)        cout << a <<” Greatest “;    else        cout << b << “ Greatest”;    cout <<”Values of f is : “<< f;    f + = 13;    cout << “Now Value of f is” << f;}
5. Write a program to find factorial of a given number. 4
// C++ program to illustrate the// before_begin() function#include <bits/stdc++.h>using namespace std;  int factorial(int n){    if (n == 0 || n == 1)        return 1;    else        return n * factorial(n - 1);}  int main(){    int n;    cout << "enter the number";    cin >> n;    cout << "the factorial is: " << factorial(n);    return 0;}
6. Write a function to accept a String Str, a character Ch and an integer pos. Now in String ‘Str’ character at position ‘pos’ should be replaced with character ‘Ch’ 4
// C++ program for above implementation#include <iostream>using namespace std;  // Function to print the stringvoid printString(string str, char ch, int pos){      // If given count is 0    // print the given string and return    if (pos == 0) {        cout << str;        return;    }      str[pos - 1] = ch;    cout << str;}  // Drivers codeint main(){    string str = "geeks for geeks";    char ch = 'x';    int pos = 5;    printString(str, ch, pos);    return 0;}
7. Write a program to read a Matrix ant print the Transpose of that Matrix . 4
#include <iostream>#define N 4  // This function stores transpose of A[][] in B[][]void transpose(int A[][N], int B[][N]){    int i, j;    for (i = 0; i < N; i++)        for (j = 0; j < N; j++)            B[i][j] = A[j][i];}  int main(){    int A[N][N] = { { 1, 1, 1, 1 },                    { 2, 2, 2, 2 },                    { 3, 3, 3, 3 },                    { 4, 4, 4, 4 } };    int B[N][N], i, j;    transpose(A, B);    printf("Result matrix is \n");    for (i = 0; i < N; i++) {        for (j = 0; j < N; j++)            printf("%d ", B[i][j]);        printf("\n");    }    return 0;}
8. a. What are the types of selection statements available in C++? Give example of each type. 2Selection statements in programming languages decides the direction of flow of program execution. Decision making statements available in C++ are:
if statement
if..else statements
nested if statements
if-else-if ladder
switch statements
Refer : Decision making in C/C++
b Differentiate between system software and application software. 2
System Software: These are the software that directly allows the user to interact with the hardware components of a computer system. The system software can be called the main software of a computer system as it handles the major portion of running a hardware.Example: Operating System
Application Software: These are the basic software used to run to accomplish a particular action and task. These are the dedicated software, dedicated to performing simple and single tasks.Example: Microsoft Excel – Used to prepare excel sheets.
Refer: Software Concepts
c. Differentiate between compiler and interpreter. 2
A compiler takes entire program and converts it into object code which is typically stored in a file. The object code is also referred as binary code and can be directly executed by the machine after linking.Examples: C and C++.
An Interpreter directly executes instructions written in a programming or scripting language without previously converting them to an object code or machine code.Examples: Perl, Python and Matlab.
Refer: Compiler vs Interpreter
d. Explain unary, binary and ternary operators? Give example of each type. 3
Unary Operators: Operators that operates or works with a single operand are unary operators.Example: (++, –)
Binary Operators: Operators that operates or works with two operands are binary operators.Example: +, –, *, /.
Ternary Operator: These operator requires 3 expressions or operands to function.Example: Conditional operator- Expression1 ? Expression2 : Expression3 .Here, Expression1 is the condition to be evaluated. If the condition(Expression1) is True then we will execute and return the result of Expression2 else return the result of Expression3.
Refer: Operators in C++
e. What is the difference between break and continue? Give example. 3
Break statement:the break statement terminates the smallest enclosing loop (i. e., while, do-while, for or switch statement)
the break statement terminates the smallest enclosing loop (i. e., while, do-while, for or switch statement)
Continue statement:the continue statement skips the rest of the loop statement and causes the next iteration of the loop to take place.
the continue statement skips the rest of the loop statement and causes the next iteration of the loop to take place.
Refer: Break and Continue statement
SECTION D
1. What are memory devices? Discuss RAM and ROM in detail 4
Random Access Memory (RAM) : It is also called as read write memory or the main memory or the primary memory. The programs and data that the CPU requires during execution of a program are stored in this memory.It is a volatile memory as the data loses when the power is turned off.
Read Only Memory (ROM) : Stores crucial information essential to operate the system, like the program essential to boot the computer.It is not volatile and always retains its data. ROMs are used in embedded systems or where the programming needs no change.
Refer: RAM and ROM
2. Explain the following terms ( 1 mark each)
a. REGISTER :These are the special fast storage devices which are used to store data directly in the CPU. A CPU contains a register file containing several registers to store the data which is currently in execution in CPU.
b. ALU : The arithmetic logic unit is that part of the CPU that handles all the calculations the CPU may need, e.g. Addition, Subtraction, Comparisons. It performs Logical Operations, Bit Shifting Operations, and Arithmetic Operation
c. NON-IMPACT PRINTER : These printers use non-Impact technology such as ink-jet or laser technology. There printers provide better quality of O/P at higher speed.Example: Ink-Jet Printer
3. What is the difference between online and offline UPS? 2Online UPS systems draw their power through power conditioning and charging components during normal operations.Offline UPS are systems where the load is fed directly from the raw mains during normal operations, rather than the inverter outputs, to the extent that power storage components such as chargers, inverters and batteries are offline as the load is concerned.
CBSE - Class 11
school-programming
C++
School Programming
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Python Dictionary
Reverse a string in Java
Interfaces in Java
Operator Overloading in C++
Polymorphism in C++