Open In App

CBSE Class 11 C++ Sample Paper-3

Class- XI [Computer Science]
Time Duration: 3 Hrs
M. M. 70
General instructions:
(i) All questions are compulsory
(ii) Programming language : C++

SECTION A



1. Explain any 2 important features of an Operating System. 2
There are various features of an Operating System. These are:

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? 2
A 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. 2
Copy 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 comment
Multi-line comment
Refer: Comments in C++

b. Identifiers
Identifiers 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. 3
Error is an illegal operation performed by the user which results in abnormal working of the program.
Type of errors :

Refer: Errors in C++

3. Explain the term LIVEWARE. 1
The 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. 5
You 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 code
int 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/a
Output: 6
b) c = ( a++) * d + b
Output: 8.5
c) 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 string
void 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 code
int 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. 2
Selection statements in programming languages decides the direction of flow of program execution. Decision making statements available in C++ are:

Refer : Decision making in C/C++

b Differentiate between system software and application software. 2

Refer: Software Concepts

c. Differentiate between compiler and interpreter. 2

Refer: Compiler vs Interpreter

d. Explain unary, binary and ternary operators? Give example of each type. 3

Refer: Operators in C++

e. What is the difference between break and continue? Give example. 3

Refer: Break and Continue statement

SECTION D

1. What are memory devices? Discuss RAM and ROM in detail 4

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? 2
Online 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.


Article Tags :