Change language

CBSE Class 11 C ++ | Sample paper-1

| | |

{1} All questions are required.
{2} C++ programming language

Q.1 [A] Explain the functional components of the computer? 2
There are several basic components that help the operating cycle of a computer, and these are called functional components of a computer. They are:
1) Input system
2) Memory organization
3) Output system
See: Computer functional components

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

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

Software:
1 ) It is the main software used to carry out a specific action and task.
2) This is specialized software designed to perform simple and single tasks.
3) They are of two types:
General purpose application software
Special application software

See: Software Concepts

[C] Define a hybrid computer? 1
Hybrid computers use both analog and digital technologies to ensure the speed of an analog computer and the accuracy of a digital computer. These computers accept digital or analog signals, but extensive digital-to-analog and analog-to-digital data conversion needs to be done. Hybrid computers are used as a cost-effective tool for complex simulations.

[D] What function the operating system plays for memory management. 1
In a computer, the processor and I / O devices interact with memory. When a program needs to be executed, it is loaded into main memory before execution completes. Common memory management techniques used by the operating system are:
Partitions: Shared memory is divided into different partitions of the same size or different sizes. This helps to fit the number of programs into memory.
Virtual memory: is a method used by the operating system by which the user can load programs that are larger than the main memory of the computer.

Q.2 [ A] Record the differences between logical and syntax errors 2
Logical errors. These types of errors that provide incorrect output but do not appear to contain errors are called logical errors ... These errors depend solely on the logical thinking of the programmer.
Syntax errors: Errors that occur when the rules for writing C / C++ syntax are violated are called syntax errors. This compiler error indicates what needs to be fixed before the code can be compiled.
mean by the reliability of the program? 2
Reliability — it is the ability of a computer program to deal with run-time errors and deal with erroneous data. Thus, to be reliable, the program must be able to process incorrectly entered data and perform correctly on all types of inputs.

[C] What is a security code. 1
Security code in a programming language is an integrity precondition check that is used to avoid errors at runtime.

[D] What is the name of the process of translating an algorithm into a program ? 1
The process of coding in a particular language is called translating an algorithm into a program.

[E] What are the characteristics of a good program? 2
The program must be designed to enable the computer to function properly and must be easy to understand. A computer program must have some important characteristics:
Flexibility : The program must be flexible enough to handle most 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 correct message for the user to enter data and display the result, in addition to making the program easy to understand and modify.
Portability . Portability refers to the ability of an application to run on different platforms (operating systems) with little or no modification.
Reliability . It is the ability of a program to perform its functions accurately, even if there are even small changes in the computer system.
Self-documenting code . Source code that uses a suitable name for identifiers (variables and methods) is called self-documenting code.

[F] What are two types of compilation errors? 2

1) Syntax errors : These compiler errors indicate what must be fixed before the code can be compiled. All of these errors are detected by the compiler and are thus known as compile-time errors.
The most common syntax errors are:
Missing parenthesis (})
Printing the value of a variable without declaring it
Missing semicolon, etc.
2) Logic errors : When compiling and executing a program, the desired output is not produced when certain input values ​​are given.
3) Runtime Error: Errors that occur during program execution (runtime) after successful compilation are called time errors. One of the most common runtime errors is division by zero, also known as division error.

Q.3 [A] Name the header files that include the following: 2
1. getch () : conio.h
2. isdigit () : ctype.h
3. sqrt () : math
4. atoy () : stdlib.h

[B] write output for the following code: 2

int val, n = 1000;

cin"" val;
res = n + val" 1500? 100: 200;
cout ""res;

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

[C] Write the equivalent C++ 2 expressions
(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 / 2mv 2
Expression: 1/2 * m * v * v; or s = 1/2 * m * pow (v, 2);

(4) x = -b +? (B 2 -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] Specify the difference between the key word and identifier. 2

Identifiers :
1) Identifiers are used as a general terminology for naming variables, functions and arrays.
2) These are user-defined names consisting of an arbitrary long sequence of letters and numbers with a letter or underscore (_) as the first character. Identifier names must be distinct in spelling and case from any keywords.
3) There are certain rules to follow when naming identifiers c:
They must begin with a letter or an underscore (_).
They should only contain letters, numbers or underscores. Other special characters are not allowed.
It shouldn’t be a keyword.
It must not contain spaces.
The length should be no more than 31 characters, since only the first 31 characters are significant.

Q.4 [A] Draw flowchart that outputs the least of the three data if not. 2

[B] Rewrite the next program after removing syntax errors. 2

# 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 undefined error.

cout ""x;

}

void main ()

{

const int MAX = 0;

int a, b;

cin"" a"" b;

if (a" b)

MAX = a;

for ( int x = 0; x "MAX; x ++) // х - undefined character

cout ""x;

[C] Write a program in C++ for printing Fibonacci series : 0, 1, 1, 2, 3, 5, 8. . 3

# 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;

}

[D] Write a program in

# 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;

}

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

# 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;

}

[B] Find the total number of elements and the total size of the following array: 2
(I) Int student [20] (II) swim A [4] [5]

i) total number of items = 20
total size = 20 * 2 = 40 bytes
ii) total number of items = 4 * 5 = 20
total size = 4 * 4 * 5 = 80 bytes

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

# include "iostream.h"
main ()
{

int sum [2, 4];

for (i = 0 ; i "2; i ++)

for (j = 0; j "= 3; i ++) {

cout ""sum;

}

[D] Check the output for the following program: 4

# 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;
}

[E] Write a C++ program to find the sum of the rows and columns of a matrix. 3

# 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 & lt ; "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 & gt ;" a [i] [j];

sum (a, n);

return 0;

}

[F] Give the correct array declaration for the following: — 2
(i) Declare an integer array A that can contain 30 values.
(ii) declare a two-dimensional array named MIN, 4 * 5 an integer.
(i) int A [30];
(ii) int MIN [4] [5];

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

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

# include "iostream.h"

void Execute ( int & amp; 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;

}

Output:

(i) a = 120
(II) B = 20

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

# 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 "& lt;  "" enter x and n ";

  cin

  " & gt ; x"" n printf ( "%. 2f " , sum (x, n));

  return 0;

}

<

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method