CBSE Class 11 C++ | Sample Paper-1

Instructions:

{1}All Question are compulsory.
{2}Programming language :c++

Q.1 [A] Explain functional components of a Computer? 2
There are a few basic components that aids the working-cycle of a computer and these are called as the functional components of a computer. They are:
1) The Input System
2) Memory Organisation
3) Output System
Refer: Functional components of a Computer



[B] Write different between application software and system software. 2

System software:
1) These are the software that directly allows the user to interact with the hardware components of a computer system.
2) The system software can be called the main software of a computer system as it handles the major portion of running a hardware.
3) This System Software can be further divided into:
The Operating System
The Language Processor

Application Software:
1) These are the basic software used to run to accomplish a particular action and task.
2) These are the dedicated software, dedicated to performing simple and single tasks.
3) These are divided into two types:
The General Purpose Application Software
The Specific Purpose Application Software

Refer: Software Concepts

[C]Define Hybrid computer? 1
Hybrid Computers use both analog and digital technology to provide speed of analog computer and the accuracy of a digital computer. These computers accept digital or analog signals but an extensive conversion of data from digital to analog and analog to digital has to be done. Hybrid Computers are used as a cost effective means for complex simulations.

[D]What function of operating system plays to manage memory. 1
In a computer, both the CPU and the I/O devices interact with the memory. When a program needs to be executed it is loaded onto the main memory till the execution is complete. The common memory management techniques used by the operating system are:
Partitioning: The total memory is divided into various partitions of same size or different sizes. This helps to accommodate number of programs in the memory.
Virtual Memory: This is a technique used by the operating system by virtue of which the user can load the programs which are larger than the main memory of the computer.

Q.2[A]Write differences between logical errors and syntax errors 2
Logical Errors: These types of errors which provide incorrect output but appears to be error free are called logical errors. These errors solely depend on the logical thinking of the programmer
Syntax errors: Errors that occur when you violate the rules of writing C/C++ syntax are known as syntax errors. This compiler error indicates something that must be fixed before the code can be compiled.
logical errors and syntax errors.

[B]What do you mean by robustness of a program. 2
Robustness is the ability of a computer program to cope with errors during execution and cope with erroneous input. So, in order to be robust, the program should be able to handle wrongly input data with perform correctly over all types of inputs.

[C]What is guard code. 1
Guard code in a computer programming language is a check of integrity preconditions which are used to avoid errors during execution.

[D]What is the process of translation of the algorithm, into a program, called? 1
The process of coding in a specific language is termed as translation of algorithm into a program.


[E] What are the characteristics of a good program ? 2
A program should be developed to ensure proper functionality of the computer and also should be easy to understand. A computer program should have some important characteristics, which are as follows:
Flexibility: A program should be flexible enough to handle most of the changes without having to rewrite the entire program.
User Friendly: A program that can be easily understood by all types of users. In addition, the proper message for the user to input data and to display the result, besides making the program easily understandable and modifiable.
Portability: Portability refers to the ability of an application to run on different platforms (operating systems) with or without minimal changes.
Reliability: It is the ability of a program to do its intended function accurately even if there are even small changes in the computer system.
Self-Documenting Code: The source code, which uses suitable name for the identifiers (variables and methods), is called self-documenting code.

[F] Name two types of compilation errors ? 2

1) Syntax errors: These compiler errors 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.
Most frequent syntax errors are:
Missing Parenthesis (})
Printing the value of variable without declaring it
Missing semicolon etc
2) Logical Errors: On compilation and execution of a program, desired output is not obtained when certain input values are given.
3) Run-time Errors: Errors which occur during program execution (run-time) after successful compilation are called run-time errors. One of the most common run-time error is division by zero also known as Division error.

Q.3[A]Name the header files to which the following belongs to : 2
1. getch(): conio.h
2. isdigit(): ctype.h
3. sqrt(): math.h
4. atoi(): stdlib.h

[B]Write output for following code: 2

filter_none

edit
close

play_arrow

link
brightness_4
code

int val, n = 1000;
cin >> val;
res = n + val > 1500 ? 100 : 200;
cout << res;

chevron_right


i) If the input is 1000. : 100
ii) If the input is 200. : 200

[C] Write the equivalent c++ expressions 2
(1) p=2(l+b)
Expression: p=2*(l+b);

(2) z=2(p/q)2
Expression: z=2*pow((p/q), 2)) or 2*p/q*p/q

(3) s=1/2mv2
Expression: 1/2*m*v*v; or s=1/2*m*pow(v, 2);

(4) x=-b+?(b2-4ac) /2a
Expression: x=-b+sqrt(b*b-4*a*c)/2*a; or x=-b+sqrt(pow(b, 2)-4*a*c)/2*a;


[D] Write difference between keyword and identifier. 2

Keywords:
1) Keywords are pre-defined or reserved words in a programming language
2) Each keyword is meant to perform a specific function in a program. Since keywords are referred names for a compiler, they can’t be used as variable names.
3) C language supports 32 keywords while in C++ there are 31 additional keywords other than C Keywords.
Identifiers:
1) Identifiers are used as the general terminology for naming of variables, functions and arrays.
2) 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.
3) There are certain rules that should be followed while naming c identifiers:
They must begin with a letter or underscore(_).
They must consist of only letters, digits, or underscore. No other special character is allowed.
It should not be a keyword.
It must not contain white space.
It should be up to 31 characters long as only first 31 characters are significant.

Q.4[A] Draw a flowchart that print the smallest of three given no. 2

[B] Rewrite the following program after removing syntactical errors. 2

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream.h>
Void main()
{
    const MAX = 0; // Error
    int a, b;
    cin << a >> b; // Error
    if (a > b)
        MAX = a;
    for (x = 0; x < MAX; x++) // x undeclared error.
        cout << x;
}

chevron_right


filter_none

edit
close

play_arrow

link
brightness_4
code

void main()
{
    const int MAX = 0;
    int a, b;
    cin >> a >> b;
    if (a > b)
        MAX = a;
    for (int x = 0; x < MAX; x++) // x is an undefined symbol
        cout << x;

chevron_right


[C] Write a program in c++ to print Fibonacci series: 0, 1, 1, 2, 3, 5, 8.. 3

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
using std::cout;
void fib(int n)
{
    int a = 0, b = 1, c;
    if (n >= 0)
        cout << a << " ";
    if (n >= 1)
        cout << b << " ";
    for (int i = 2; i <= n; i++) {
        c = a + b;
        cout << c << " ";
        a = b;
        b = c;
    }
}
  
// Driver code
int main()
{
    int n;
    cout << "Enter the value of n";
    cin >> n;
    fib(n);
    return 0;
}

chevron_right


[D] Write a program in c++ to find out factorial of a given no. 3

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
using namespace std;
  
int fact(int n)
{
    if (n == 1 || n == 0)
        return 1;
    return n * fact(n - 1);
}
  
int main()
{
    int n;
    cout << "Enter the number";
    cin >> n;
    cout << "factorial of n is" << fact(n);
    return 0;
}

chevron_right


Q.5[A] Write a program in c++ to replace every space in a string with hyphen. 2

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
#include <string.h>
using namespace std;
  
void replace(char* str, int len)
{
    for (int i = 0; i < len; i++) {
        if (str[i] == ' ')
            str[i] = '_';
    }
    cout << str;
}
  
int main()
{
    char str[] = "geeks for geeks";
    int len = strlen(str);
    replace(str, len);
    return 0;
}

chevron_right


[B] Find the total no. of elements and total size of the following array: 2
(i) int student[20] (ii) float A[4][5]

i) total no. of elements = 20
total size = 20*2 = 40 bytes
ii) total no. of elements =4*5=20
total size =4*4*5= 80 bytes

[C] Rewrite the following program after removing syntactical errors 2


filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream.h>
main()
{
    int sum[2, 4];
    for (i = 0; i < 2; i++)
        for (j = 0; j <= 3; i++) {
            cout << sum;
        }

chevron_right


[D] Find out the output for the following program: 4

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream.h>
main()
{
    int a[5] = { 5, 10, 15, 20, 25 };
    int i, j, k = 1, m;
    i = ++a[1];
    j = a[2]++;
 m= a[i++
};
cout << i << j << k << m;
}

chevron_right


[E] Write a program in c++ to find row and column sum of a matrix . 3

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
using namespace std;
#define MAX 10
  
int sum(int a[][MAX], int n)
{
    int i, j;
    int sum = 0;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (i == 0 || j == 0 || i == (n - 1) || j == (n - 1))
                sum = sum + a[i][j];
        }
    }
    cout << sum;
    return 0;
}
  
int main()
{
    int a[10][10];
    int n, i, j;
    cout << "enter the dimension of matrix";
    cin >> n;
    cout << "enter the elements";
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            cin >> a[i][j];
    sum(a, n);
    return 0;
}

chevron_right


[F] Give the proper array declaration for the following :- 2
(i) Declare an integer array A which can hold 30 values.
(ii) declare a two dimensional array called MIN, 4* 5 of integer.
(i) int A[30];
(ii)int MIN[4][5];

Q.6[A] What are the 3 steps using a function . 3
The three steps of using a function correctly is:
i) Function declaration: Function prototype is declared, so that compiler can know about the parameters and return types of a function
ii) Function definition: The entire body and functionality of a function is designed and written inside the function block.
iii) Function calling: Finally after definition and declaration of a function, it is called inside the driver/main function to perform the desired functionality.

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

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream.h>
void Execute(int& x, int y = 200)
{
    int temp = x + y;
    x + = temp;
    if (y != 200)
        cout << temp << x << y;
}
main()
{
    int a = 50, b = 20;
    Execute(a, b);
    cout << a << b;
}

chevron_right


Output:

(i) a= 120
(ii)b=20

[C] Write a function in C++ having 2 parameters x and n of integer type with result type float to find the sum of following series :-
1 + x/2! + x2/3! +…………………..+xn/(n+1)! 3

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
#include <math.h>
  
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(i + 1));
    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;
}

chevron_right


[D] Write a program to calculate the sum of n natural numbers by using function.
3

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
using namespace std;
int sum(int n)
{
    int i, sum;
    sum = 0;
    for (i = 1; i <= n; i++) {
        sum = sum + i;
    }
    cout <<”sum of natural numbers is”<< sum;
}
  
int main()
{
    int n;
    cout << "enter the range of sum";
    cin >> n;
    sum(n);
    return 0;
}

chevron_right


Q.7[A] Convert the following into its binary equivalent codes. 4
(i) (84)10 = (?)2
= (1010100)2
(ii) (2C9)16 = (?)10
= (2C9)16 = (001011001001)2 = (713)10
(iii) (101010)2= (?)10
= (42)10
(iv) (3674)8 =(?)2
= (11110111100)2


Refer: Number System and base conversions

[B] Express -4 in 1’s complement form. 1

[C] What is the function of a bus . 1
Bus is a group of conducting wires which carries information, and all the peripherals are connected to microprocessor through Bus.

[D] Write two types of cache memory. 2
The two types of cache memory are L1 and L2 Cache.

[D] write difference between SRAM and DRAM. 2
SRAM has lower access time. So it is faster than DRAM.
SRAM is costlier.
DRAM has higher access time. So it is slower than DRAM.
DRAM is cheaper.

Refer: SRAM and DRAM



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.