Open In App

CBSE Class 11 C++ | Sample Paper -2

Improve
Improve
Like Article
Like
Save
Share
Report

Model Question Paper
Class- XI
Computer Science
M.M: 70 Time: 3 hrs.
Instructions:
1. All Question are compulsory.
2. Programming language :C++

Q.1[A] How is a compiler different from interpreter ? 2
Compiler and Interpreter are two different ways to execute a program written in a programming or scripting language.

  • Compiler takes entire program and converts it into object code which is typically stored in a file. The object code is also refereed as binary code and can be directly executed by the machine after linking. Examples of compiled programming languages are C and C++.
  • Interpreter directly executes instructions written in a programming or scripting language without previously converting them to an object code or machine code. Examples of interpreted languages are Perl, Python and Matlab.

Refer: Compiler vs Interpreter

[B] What do you understand by application software ? 2
These are the basic software used to run to accomplish a particular action and task. These are the dedicated software, dedicated to perform simple and single tasks. These are divided into two types:
a) The General Purpose Application Software:
Microsoft Excel – Used to prepare excel sheets.
VLC Media Player – Used to play audio/video files.
Adobe Photoshop – Used for designing and animation and many more.
b) The Specific Purpose Application Software:
Ticket Reservation System
Healthcare Management System
Refer: Software Concepts

[C] Who invented the punched card ? 1
Herman Hollerith invented the punch card.

[D] Name the super computers developed in India ? 1
The super computers developed in India are: PARAM, ANURAG

Q.2[A] What is meant by Graceful Degradation ? 2
Graceful degradation is the ability of a computer, machine, electronic system or network to maintain limited functionality even when a large portion of it has been destroyed or rendered inoperative.

[B] Why are logical Errors harder to locate ? 2
The type of errors which provide incorrect output but appears to be error free are called logical errors. These are one of the most common errors done by beginners of programming.
Logical Errors are difficult to find because isolating these errors solely depends on the logical thinking of the programmer and can only be detected, if we follow the line of execution and determine why the program takes a specific path of execution.
Refer: Logical Errors

[C] Write steps required to develop a program and explain the steps briefly. 3
Program development requires 6 phases, they are as follows:
Problem Definition.
Problem Analysis.
Algorithm Development.
Coding & Documentation.
Testing & Debugging.
Maintenance.

Q3[A] Name the header files to which the following belongs to:- 2
(i)exit(): process.h
(ii) gets(): stdio.h
(iii) tolower(): ctype.h
(iv) malloc(): stdlib.h

[B] What will be the output of the following statements: 2
(i) a = sqrt(16): 16
(ii) b= strlen(“COMPUTER”): 8
(iii)c = ceil(13.45): 14
(iv) d =abs(-6): 6

[C] What is the purpose of sizeof operator ? 2
Sizeof is a compile time unary operator which can be used to compute the size of its operand. The result of sizeof is an unsigned integral type. Sizeof can be applied to any data-type, including primitive types such as integer and floating-point types, pointer types, or compound datatypes such as Structure, union etc.
Refer: sizeof operator

[D] Write differences between Unary Operator and Binary Operator 2
Unary operator: The operators that act upon a single operand to produce a new value.
Types of unary operators: unary minus(-), increment(++), decrement(–), NOT(!), Address of operator(&) and sizeof() operator
Binary Operator: Operators that operates or works with two operands are binary operators. example: Types of Binary operators: Addition (+), Subtraction (–), Multiplication (*), Division(/) etc.
Refer: Unary operators in C/C++, Operators in C++

Q.4[A] Write differences between entry controlled loop and exit controlled loop 2

  • Entry Controlled loops: In this type of loops the test condition is tested before entering the loop body. Example: For Loop and While Loop are entry controlled loops.
  • Exit Controlled Loops: In this type of loops the test condition is tested or evaluated at the end of loop body. Therefore, the loop body will execute atleast once, irrespective of whether the test condition is true or false. Example: Do while loop is exit controlled loop.

Refer: Loops in C++

[B] Write a program to input a character and to print whether a given character is an alphabet, digit or any other character.
Logic: All characters whether alphabet, digit or special character have ASCII value. Input character from the user will determine if it’s Alphabet, Number or Special character.
ASCII value ranges-
For capital alphabets 65 – 90
For small alphabets 97 – 122
For digits 48 – 57
All other cases are Special Characters.




// CPP program to find type of input character
#include <iostream>
using namespace std;
  
void charCheck(char input_char)
{
    // CHECKING FOR ALPHABET
    if ((input_char >= 65 && input_char <= 122))
        cout << " Alphabet ";
  
    // CHECKING FOR DIGITS
    else if (input_char >= 48 && input_char <= 57)
        cout << " Digit ";
  
    // OTHERWISE SPECIAL CHARACTER
    else
        cout << " Special Character ";
}
  
// Driver Code
int main()
{
    char input_char = '$';
    charCheck(input_char);
    return 0;
}


[C] Give the output for the following program segment: 2




i.for (int i = 10; i > 6; i = i - 2)
        cout
    << i << endl;
  
Output : 10, 8
  
                 (ii) for (int i = -5; i > -7; i--)
                     cout
                 << i + 1 << endl;
>
  
    Output : -4,
    -5


Q.5[A] what is the difference between following two statements :- 1
(i) int sum[10];
(ii) int sum[10]= 20;
The difference between these two statements are :
in first statement, an integer array of 10 elements has been declared and values are not assigned to the elements of the array.
In the second statement, an integer array of 10 elements has been declared and all the elements of the array have been assigned the value = 20

[B] Rewrite the following program after removing the syntactical errors.underline each
correction. 3




#include <iostream.h>
main()
{
 int x[5], y, z[5]
 for( i=0;i<5;i++
 {
        x[i] = i;
        z = i + 3;
        y = z;
        x = y;
 }
}
  
// Correct code:
  
void main()
{
    int x[5], y, z[5];
    for (int i = 0; i < 5; i++) {
        x[i] = i;
        z = i + 3;
        y = z;
        x[i] = y;
    }
}


[C] Find the output of the following program: 2




#include <iostream.h>
main()
{
    int a[4], i;
    for (i = 0; i < 4; i++)
        a[i] = 5 * i;
    for (i = 0; i < 4; i++)
        cout << a[i];
}


Output: 0, 5, 10, 15

[D] Write a program to read a string and print how many words are stored in the string. 3




// C++ program to count no of words
// from given input string.
#include <iostream>
using namespace std;
#define OUT 0
#define IN 1
  
// returns number of words in str
unsigned countWords(char* str)
{
    int state = OUT;
    unsigned wc = 0; // word count
  
    // Scan all characters one by one
    while (*str) {
        // If next character is a separator, set the
        // state as OUT
        if (*str == ' ')
            state = OUT;
  
        // If next character is not a word separator and
        // state is OUT, then set the state as IN and
        // increment word count
        else if (state == OUT) {
            state = IN;
            ++wc;
        }
  
        // Move to next character
        ++str;
    }
    return wc;
}
  
// Driver program to test above functions
int main(void)
{
    char str[] = "One two three  four five  ";
    cout<<"No of words : %u"<<countWords(str));
    return 0;
}


[E] Write a program to find the sum of array elements. 3




#include <iostream>
using namespace std;
  
int arraysum(int arr[], int n)
{
    int i, sum = 0;
    for (i = 0; i < n; i++)
        sum = sum + arr[i];
    cout << sum;
    return 0;
}
  
int main()
{
    int arr[10];
    int i;
    cout << "enter array elements";
    for (i = 0; i < 10; i++)
        cin >> arr[i];
    arraysum(arr, 10);
    return 0;
}


Q.6[A] What do you mean by function prototype ? 1
Function prototype tells compiler about number of parameters function takes, data-types of parameters and return type of function. By using this information, compiler cross checks function parameters and their data-type with function definition and function call.
Refer: Function prototype

[B] What is meant by scope ? Name all kinds of scope is supported by C++. 3
In programming scope of a variable is defined as the extent of the program code within which the variable can we accessed or declared or worked with. There are mainly two types of variable scopes as discussed below:
Local Variables
Variables defined within a function or block are said to be local to those functions.
Global Variables
As the name suggests, Global Variables can be accessed from any part of the program. They are available through out the life time of a program. They are declared at the top of the program outside all of the functions or blocks.
Refer: Scope of variables in C++

[C] Find the output of the following: 3




#include <iostream.h>
int max(int& x, int& y, int& z)
{
    if (x > y && y > z) {
        y++;
        z++;
        return x;
    }
    else {
        if (y > x)
            return y;
        else
            return z;
    }
    void main()
    {
        int a = 10, b = 13, c = 8;
        a = max(a, b, c);
        cout << a << b << c;
        b = max(a, b, c);
        cout << ++a << ++b << ++c << endl;
    }


With a=10, b=13, c=8 when first time max(a, b, c) is called, the output is:
13 13 8
Second time when the function is called, b is assigned a value 8, and the output is:
14 9 9

[D] Write a complete C++ Program that reads a float array having 15 elements. The program uses a function reverse() to reverse this array. 4




#include <iostream>
using namespace std;
  
// function to swap elements
int swap(float* a, float* b)
{
    float temp;
    temp = *a;
    *a = *b;
    *b = temp;
}
// function to reverse the elements by
// swapping each element from the start
// and the end
  
int reverse(float arr[])
{
    int i = 0, j = 14;
    while (i < j) {
        swap(&arr[i], &arr[j]);
        i++;
        j--;
    }
    for (i = 0; i < 15; i++)
        cout << arr[i] << endl;
    return 0;
}
  
// driver function
int main()
{
    float arr[5] = { 0 };
    int i;
    cout << "enter the elements";
    for (int i = 0; i < 15; i++)
        cin >> arr[i];
    reverse(arr);
}


[E] Write a C++ function having two parameters x of type float and n of type integer with result type float to find the sum of following series :-
1 + x/2! + x2/4! + x3/6! +……………………+ xn/2n!




#include <iostream>
#include <math.h>
using namespace std;
  
int fact(int z)
{
    if (z == 1)
        return 1;
    return x * fact(x - 1);
}
  
double sum(int x, int n)
{
    double i, total = 1.0;
    for (i = 1; i <= n; i++)
        total = total + (pow(x, i) / fact(2 * i));
    return total;
}
  
// Driver code
int main()
{
    int x;
    int n;
    cout << "" enter x and n ";
                               cin
                               >> x >> n printf("%.2f", sum(x, n));
    return 0;
}


Q.7[A] Difference between online UPS 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.

[B] Explain what are the two categories of printers ? 2
Printers are Output devices used to prepare permanent Output devices on paper. Printers can be divided into two main categories :
Impact Printers: In this hammers or pins strike against a ribbon and paper to print the text. This mechanism is known as electro-mechanical mechanism. They are of two types.
Example:
Character Printer : It prints only one character at a time. It has relatively slower speed. Eg. Of them are Dot matrix printers.
Dot Matrix Printer : It prints characters as combination of dots. Dot matrix printers are the most popular among serial printers.
Non-Impact Printers: There 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

[C] What is access time. 1
Access time is the time from the start of one storage device access to the time when the next access can be started. Access time consists of latency (the overhead of getting to the right place on the device and preparing to access it) and transfer time.
The term is applied to both random access memory (RAM) access and to hard disk and CD-ROM access

[E] Convert the following into its binary equivalent number system :- 3
(i) (EB4A)16 = (60234)10
(ii) (84)10 = (1010100)2
(iii)(B2F)16 = (5457)8

For details, refer: Base conversions

[F] Find the eight bit one’s complement form of the following: 2
(i) -14 (ii) -49
Solution: 1’s complement of a negative number is computed by flipping the bits of its binary representation.
-14 = -(00001110)2 = (11110001)1’s
-49 = -(00110001)2 = (11001110)1’s



Last Updated : 23 Oct, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads