You are on page 1of 35

Computer Science (Theory) Class XI Code: 083 Design of Question Paper for 2010-2011

Time: 3 Hours M.M. 70

Weightage of marks over different dimensions of the question paper shall be as follows: A. Weightage to different topics/content units S.No. 1 2 3 4 Topics Computer Fundamentals Programming Methodology Introduction to C++ Programming in C++ Marks 10 10 15 35

B. Weightage to different forms of questions S.No. Forms of Questions

1 2 3 4

Very Short Answer questions(VSA) Short answer questions-Type I (SA I) Short answer questions-Type II (SA II) Long answer questions (LA)

Marks Number for each of questions questions 1 14 2 15 3 6 4 2

Total Marks 14 30 18 8

C. Scheme of Options There will be no overall choice. All questions are compulsory. D. Difficulty level of questions S.No. 1 2 3 Estimated difficulty level Easy Average Difficult Percentage of Marks 15% 70% 15%

Based on the above design, two sets of sample papers along with their blue prints and Marking schemes have been included in this document. About 15% weightage has been assigned to questions testing higher order thinking (HOT) skills of learners.

SAMPLE QUESTION PAPER SET I


COMPUTER SCIENCE (083) Class XI

BLUE PRINT
S.No. UNIT VSA
(1 Mark)

SA I
(2Marks)

SAII
(3 Marks)

LA
(4 Marks)

TOT AL
(70 Marks)

COMPUTER FUNDAMENTALS
a) Software concepts & Operating System b) Number System c) Encoding, Microprocessor & Memory Concepts

1(1) 4(4) 3(3)

2(1)

3(2) 4(4) 3(3)

PROGRAMMING METHODOLOGY
a) General Concepts b) Problem Solving Methodology and Technique

3(3) 1(1)

4(2) 2(1)

7(5) 3(2)

INTRODUCTION TO C++
a) Getting Started b) Data Types, Variables and Constants c) Operators and Expressions

1(1) 1(1)

4(2) 4(2) 2(1)

3(1)

4(2) 5(3) 6(5)

PROGRAMMING IN C++
a) Flow of Control b) Functions from header files(String.h, ctype.h, math.h, stdlib.h) c) User Defined Functions d) Structured Data Type : Array e) User Defined data types f) Structures

9(3) 6(3) 2(1) 2(1) 2(1) (HOTS) 30(15) 3(1) 3(1)

9(3) 6(3) 5(2) 4(1)(HOTS) 7(2) 2(1) 4(1)(HOTS) 6(2) 8(2) 70(37 )

14(14)

18(6)

SAMPLE QUESTION PAPER Set I Computer Science (083) Class XI


Time : 3 hours General Instructions:All the questions are compulsory The paper contain 7 Questions Programming language used: C++ Maximum Marks : 70

S.NO. Q1.

Sub Question Part (a) Explain the need of Operating System. (b) (c) Name any two Utility Softwares. Convert the following : i) (213)10=( ?)2 ii) (1100.01)2= ( ?)8 iii) (AF)16 = (? ) 2 iv) (56)10 = (? )8 What is the need for Cache memory ? Which technology is used for sending information through wireless devices ? 1024 KB = _____GB 1 PB = ________ KB What is debugging ? What is the difference between finite and infinite loop? What do you understand by modularity ? Give the difference between source code and object code. What are the differences between an entry controlled loop and an exit controlled loop ? What are the characteristics of a good program ? Differentiate between syntax and logical errors. Give examples. Name the header files to which the following functions belong. i) strcat( ) ii) clrscr() iii) pow() iv) isupper() What are preprocessor directives ? Explain with example.

Marks 2 1 (1*4=4)

(d) (e) (f)

1 1

1 1 1 1 1

Q2

(a) (b) (c) (d) (e)

2 2 2 2

(f) (g) Q3. (a)

(b)

(c)

Give output of the following program segments : (i) a=5; cout<<(a = = 8); (ii) int a = 10; a >10 ? cout << a : cout<< a; (iii) int x; char ch = A; x = ch; cout << x;

1*3=3

(d)

Consider the following program code: int R=25000; int S=2*R; cout<<S<<

<<R;

The above program does not give the desired output. Give reason. Also give the correct statement. (e) i) How a is different from a? ii) Name << and >> operators. 2

(f)

How many bytes of memory is allocated to a and b, if a and b are declared as below: int a; long b; Solve the following: i) 8 / 2 + 9 * 10 % 2 ii) a && b || a <= b if a = 10, b = 5

(g)

(h)

Variables a , b are integers and c is a float. If a is 15 and b is 4 then what can be done to get the result of a / b as a decimal and store the result in c. Write the appropriate statement.

(i) Q4. (a) Write a function to accept no. of calls made by user and calculate the mobile call bill as per the following criteria: No. of Calls Amount 0-50 Free 51-100 20p per call 101- 200 50 p per call 201 and above 75p per call Rent will be Rs 100 and is compulsory. (b) Give the output of the following program segment: char fname[50]= Charlie; 4 2 3

char lname[50 ]= Tango; for (int i=0; i<strlen(lname)-2;++i) lname[i] = toupper( lname[i]); puts(lname); cout<<endl; strcat(lname, ); strcat(lname,fname); cout<<lname<< <<fname; 2 (c) Consider the following program code. Select the expected output from the options(i) to (iv) # include <iostream.h> # include <stdlib.h> void main( ) { randomize(); int dice = 6, res; res = random(dice) + 1; for (int i = 1 ; i<res ; ++i) cout << I << ; } (i ) 0 1 2 3 4 (iii) 2 3 4 Also justify your answer. (d) Write a function that takes a long type variable as parameter and returns the sum of its digits. Example Input : 3264 Output : Sum is 15 Give the output of the following program: # include <iostream.h> int x=10; void increase(int a,int &b, int c) { ++a; b++; ++c; Cout << a << \t << b << \t << c; } void main() { int x = 5,y = 10; increase(x, y, ::x); cout<<\n<<::x<<\t<<x<<\t<<y } (b) Write a function count() that takes array - list, its size and an integer number as parameter and returns the numbers of times n appears in the list. Example : Input : Array is 3 4 6 12 6 7 5 2 6 4 3 ii) 1 2 3 4 5 iv) 0 1 2

Q5.

(a )

n is 6 Output : 3 (c) Write a function in C++ to print the sum of left diagonal elements and right diagonal elements of 3 x 3 matrix. Example Input : Array is 3 4 6 1 5 7 2 4 8 Output : Sum of left diagonal elements is 16 Illustrate the use of typedef with an example. Rewrite the following program after correcting the error(s), if any. Also underline the corrections made. # include<iostream.h> # include<string.h> int main( ) { int vehicleno, vehiclename[30],nowheels=0; cin>>vehicleno; gets(vehiclename); if (vehiclename= Car) nowheels=+4; } Rewrite the following code using switch case statements char ch ; int x,y,z; cin>>ch>>x>>y; if (ch= =+) z=x+y; else if (ch= = -) z = x- y; else if (ch = = *) z = x * y; else cout<<Invalid Operator; Rewrite the following using while loop int n=15, sume=0; for( int i=1; i<=n; i++) { if( i % 2 == 0 ) sume + = i ; } Declare a structure studrec which contains rollno, name, address, and phoneno. Address is also a structure ads having house no, street no, city, state and country. 3

Q6.

(a) (b)

2 2

(c)

d)

Q.7

a)

Studrec

rollno

name

address streetno
6

phoneno

houseno

city

b)

Declare a structure length that contains two members metre and centimeter of type integer. This structure is used to store distance in metres and centimeters. Write a function add_length() that takes two lengths as parameters and displays the sum of these lengths. Example Input : Length 1 m = 2 . cm = 60 Length 2 m -= 3, cm = 80 Output : Sum of lengths m = 6 cm = 40

SAMPLE QUESTION PAPER SET I Computer Science (083) Class XI MARKING SCHEME
Time : 3 hours General Instructions:All the questions are compulsory The paper contain 7 Questions Programming language used: C++ S.NO. Q1. Sub Question Part (a) Explain the need of Operating System. Ans: The need of OS is to perform : i) Disk management ii) File management iii) Memory management iv) IO management (b) Name any two Utility Softwares. Ans: i) Antivirus ii) Disk Defragmentor Convert the following : v) (213)10=( ?)2 vi) (1100.01)2= ( ?)8 vii) (AF)16 = (? ) 2 viii) (56)10 = (? )8 Ans: ix) x) xi) xii) (d) (213)10=(11010101 )2 (1100.01)2= (14.2 )8 (AF)16 = (10101111) 2 (56)10 = ( 70)8 1 Marks 2 Maximum Marks : 70

(c)

(1*4=4)

What is the need for Cache memory ? Ans: Cache is the fastest memory of computer Which technology is used for sending information through wireless devices ? Ans: Bluetooth or IR(Infra Red Rays) 1024 KB = _____GB 1 PB = ________ KB Ans: 1024 KB =10242 GB 1 PB = 10243 KB What is debugging ? Ans:

(e)

(f)

Q2

(a)

Tracing and Rectifying the errors in a program. (b) What is the difference between finite and infinite loop? Ans: Finite loop- loop where the no. iterations is finite because lower bound and upper bound have finite values Infinite loop A loop where the no. of iterations is not a finite no. due to the conditions given. The loop will go on endlessly. What do you understand by modularity ? Ans: Modularity- breaking up of a program into small modules or functions Give the difference between source code and object code. Ans: Source code- Program created by the userin high level language is source code. Eg- .cpp file Object code- After compiling the source code the resultant binary program is the object code. Eg- .obj file (e) What are the differences between an entry controlled loop and an exit 2 controlled loop ? Ans. Entry controlled loop : The condition for termination is checked before entering the loop e.g. While { }. The loop may not execute even once of the condition is not satisfied. Exit controlled loop : The condition for termination is checked after the statements in the loop. e.g.do {} while(). The loop will always execute at least once. Even if the condition is not satisfied. Illustrate with suitable example What are the characteristics of a good program ? Ans: i) program should be user friendly ii) Meaningful variable names should be used iii) Optimum use of memory iv) Low execution time Differentiate between syntax and logical errors. Give examples. Ans: Syntax errors When the rule of writing a program is not followed properly, syntax errors occurs. Eg- cout<a Logical errors- errors occurring in the concept of a program. eg- if (a= 3) Name the header files to which the following functions belong. v) strcat( ) vi) clrscr() vii) pow() viii) isupper() Ans: i) strcat( ) string.h It is used to set width ii) clrscr( ) conio.h It is used to find the absolute value. iii) Pow() math.h 9 2 1

(c)

(d)

(f)

(g)

Q3.

(a)

iv)

Isupper() ctype.h

(b)

What are preprocessor directives ? Explain with example. Ans. Preprocessor directives are lines included in the code of our programs that are not program statements but directives for the preprocessor. These lines are always preceded by a hash sign (#). Examples are # define TABLE_SIZE 100 # define getmax(a,b) a>b?a:b # include<iostream.h> Give output of the following program segments : (iv) a=5; cout<<(a = = 8); Ans : 0 (v) int a = 10; a >10 ? cout << a : cout<< a; Ans : 10 int x; char ch = A; x = ch; cout << x; Ans: 65

1 (c)

1*3=3

(vi)

(d)

Consider the following program code: int R=25000; int S=2*R; 2 cout<<S<< <<R; The above program does not give the desired output. Give reason. Also give the correct statement. Ans: The range of an int is upto -32768 to + 32767, and the output S is junk value as it exceeds limit and R will give the value 25000.

(e)

i) How a is different from a? ii) Name << and >> operators. Ans: i) 1) a is character constant and a is string constant 2) Size of a is 1 byte and size of a is 2 bytes 3) a contains a single character a and a contains two characters a and \0 ( Any two ) Ans .ii) Extraction and insertion opperators 1

(f)

How many bytes of memory is allocated to a and b, if a and b are declared as below: int a; long b;

10

Ans: i) ii) (g)

2 bytes 4 bytes 2

Solve the following: i) 8 / 2 + 9 * 10 % 2 Ans: 4 ii) a && b || a <= b if a = 10, b = 5 Ans: 1

(h)

Variables a , b are integers and c is a float. If a is 15 and b is 4 then what can be done to get the result of a / b as a decimal and store the result in c. Write the appropriate statement. Ans. c = (float) a / b ; Typecasting Write a function to accept no. of calls made by user and calculate the mobile call bill as per the following criteria: No. of Calls Amount 0-51 Free 51-101 20p per call 101- 200 50 p per call 201 and above 75p per call Rent will be Rs 100 and is compulsory. Ans: void bill(int call) { float charge; if (call<=50) charge = 100; else if((call>=51) && (call<=100)) charge=100+0.2*(call-50); else if((call>=101) && (call <= 200)) charge=100+ 0.2*50 + 0.5 * (call-100); else charge=100+0.2*50+0.5*100+0.75*(call-150); cout<<Total Charge = <<charge; }

Q4.

(a)

(b)

Give the output of the following program segment: char fname[50]= Charlie; char lname[50 ]= Tango; for (int i=0; i<strlen(lname)-2;++i) lname[i] = toupper( lname[i]); puts(lname); cout<<endl; strcat(lname, ); strcat(lname,fname); cout<<lname<< <<fname; Ans: TANgo TANgo Charlie Charlie

11

(c)

Consider the following program code. Select the expected output from the options(i) to (iv) # include <iostream.h> # include <stdlib.h> void main( ) { randomize(); int dice = 6, res; res = random(dice) + 1; for (int i = 1 ; i<res ; ++i) cout << I << ; } (i ) 0 1 2 3 4 (iii) 2 3 4 ii) 1 2 3 4 5 iv) 0 1 2

Also justify your answer. Ans: 12345 As random( ) will generate number from 0 to 5 so the value of dice will be from 0 to 5. res will be from 1 to 6. Also loop is starting from 1 so (i) ,(iii) and (iv) can not be the possible output as they are not starting from 1. (d) Write a function that takes a long type variable as parameter and returns the sum of its digits. Example Input : 3264 Output : Sum is 15 Ans. int sumdigit( long num ) { int digit, sum = 0; while( num > 0 ) { digit = num % 10 ; sum = sum + digit; num = num / 10 ; } return(sum) } Give the output of the following program: # include <iostream.h> int x=10; void increase(int a, int &b, int c) { ++a; b++; ++c; cout << a << \t << b << \t << c; } void main() { int x = 5,y = 10; 3

Q5.

(a )

12

increase(x, y, ::x); cout<<\n<<::x<<\t<<x<<\t<<y } Ans: 6 11 11 11 5 10 (b) Write a function count() that takes array - list, its size and an integer number as parameter and returns the numbers of times n appears in the list. Example : Input : Array is 3 4 6 12 6 7 5 2 6 n is 6 Output : 3 Ans: int count(int list[], int size, int n) { int ctr=0; for ( int I = 0 ; I < size; ++ i) if (list[i] == n) ctr++; return ctr; } (c) Write a function in C++ to print the sum of left diagonal elements and right diagonal elements of 3 x 3 matrix. Example Input : Array is 3 4 6 1 5 7 2 4 8 Output : Sum of left diagonal elements is 16 Ans: void sumdiag(int sqmatrix[ ][3] ) { int suml=0; for (int i = 0; i<3;++i) for (int j = 0; j<3;++j) if (i==j) suml += sqmatrix[i][j]; cout << sum of left diagonal elements is << suml; } Illustrate the use of typedef with an example. Ans : The typedef keyword allows you to create a new alias for an existing data type. For example: typedef unsigned int nint; // data1 and data2 have the same type nint data1; unsigned int data2; (b) Rewrite the following program after correcting the error(s), if any. Also underline the corrections made. # include <iostream.h> # include <string.h> int main() 2 3

Q6.

(a)

13

int vehicleno, vehiclename[30],nowheels=0; cin>>vehicleno; gets(vehiclename); if (vehiclename= Car) nowheels=+4;

} Ans: # include <iostream.h> # include <string.h> # include <stdio.h> int main( ) { int vehicleno, vehiclename[30],nowheels=0; cin>>vehicleno; gets(vehiclename); if (!strcmp(vehiclename, Car) nowheels+=4; return 0; } Rewrite the following code using switch case statements char ch ; int x,y,z; cin>>ch>>x>>y; if (ch= =+) z=x+y; else if (ch= = -) z = x- y; else if (ch = = *) z = x * y; else cout<<Invalid Operator; Ans: char ch ; int x, y, z; cin >> ch >> x >> y; switch(ch) { case + : z = x+y; break; case - : z = x-y; break; case * : z = x*y; break; default : cout<< Not a valid operator; } Rewrite the following using while loop int n=15, sume=0; for( int i=1; i<=n; i++) { if( i % 2 == 0 ) sume + = i ; } Ans: int n=15, sume=0, i = 1; while( i <= n ) { if( i % 2 == 0 ) sume + = i ; }

(c)

d)

14

Q.7

a)

Declare a structure studrec which contains rollno, name, address, and phoneno. Address is also a structure ads having house no, street no, city, state and country.

Studrec

rollno

name

address streetno

phoneno

houseno
Ans: struct ads { char houseno[25]; char streetno[25]; char city[25]; }; struct studrec { int rollno; char name[25]; ads address; long phoneno; }; b)

city

Declare a structure length that contains two members metre and centimeter of type integer. This structure is used to store distance in metres and centimeters. Write a function add_length() that takes two lengths as parameters and displays the sum of these lengths. Example Input : Length 1 m = 2 . cm = 60 Length 2 m -= 3, cm = 80 Output : Sum of lengths m = 6 cm = 40

Ans. struct length { int metre, centimeter; }; void add_length( length p1, length p2) { length p3; p3.centimeter = p2.centimeter + p1.centimeter; p3.metre = p2.metre + p1.metre; if ( p3.centimetre >= 100) { p3.centimetre = p3.centimetre % 100; p3.metre++; } cout << p3.metre << p3.cenimeter; }

15

SAMPLE QUESTION PAPER SET II


COMPUTER SCIENCE (083) Class XI

BLUE PRINT
S.No. UNIT VSA
(1 Mark)

SA I
(2Marks )

SAII
(3 Marks)

LA
(4 Marks)

TOT AL
(70 Marks)

COMPUTER FUNDAMENTALS
a) Software concepts & Operating System b) Number System c) Encoding, Microprocessor & Memory Concepts

2(2) 4(4) 2(2)

2(1)

2(2) 4(4) 4(3)

PROGRAMMING METHODOLOGY
a) General Concepts b) Problem Solving Methodology and Technique

1(1) 3(3)

2(1) 4(2)

3(2) 7(5)

INTRODUCTION TO C++
a) Getting Started b) Data Types, Variables and Constants c) Operators and Expressions

1(1) 1(1)

4(2) 2(1) 4(2) 4(2) 2(1)

3(1) 3(1) 3(1) 3(1) 6(2)

4(2) 3(2) 8(4) 7(3) 5(2) 3(1) 12(4) 2(1) 6(2) 70(37 )

PROGRAMMING IN C++
a) Flow of Control b) Functions from header files(String.h, ctype.h, math.h, stdlib.h) c) User Defined Functions d) Structured Data Type : Array e) User Defined data types f) Structures

14(14)

2(1) 2(1) 2(1) HOTS 30(15)

4(1)HOTS 4(1)HOTS

18(6)

8(2)

16

SAMPLE QUESTION PAPER SET II COMPUTER SCIENCE (083) Class XI


Time : 3 hours
General Instructions:All the questions are compulsory The paper contain 7 Questions Programming language used: C++ S.NO. Q1. Sub Questions Part (a) Define Database Management System (DBMS). Name two database packages. (b) (c ) Name any 2 anti virus software Arrange the units of storage in descending order. TB, GB, PB,MB Give the Full form of ASCII Convert the following:(1) (45.54)10 = (?)2 (2) (735)8 = (?)2 (3) (110100101111)2 = (?)10 (4) (A3F) 16 = (?)2 Differentiate between PS-2 port and serial port. Arrange in order:(i) Coding of the program (ii) Design the program (iii) Testing the program (iv) Analyze the problem (v) Understand the problem Differentiate between /**/ and // How many times the following loop will be executed:for( int i=0;i<20;i+=2) Identify the correct identifiers(any 2):(i). AS_G_D (ii) (iii) roll number (iv) (v) age123 (vi) 2wer S.I. rate 2 Marks 1

Maximum Marks : 70

1 1

(d) (e)

1X4

(f) Q2 (a)

(b) (c )

1 1

(d)

(e)

What is the purpose of Indentation? Indent the following program: #include<iostream.h> void main() {int i=0; for (i=0;i<20;i++){ cout<<i;

17

cout<<endl;} } (f) Ifelse is used instead of switch-case in certain program 2 segments, why? Explain giving examples. Identify the number of variables for input and output in the following case study:ABC bank wants to calculate Simple interest of a customer depending upon the principle value, rate of interest and time period. Note: - Simple Interest = (Principal * Rate * Time period) /100 Identify the data types for the following (i) a (ii) 0x234 Write an expression to find the greater of two variables x, y and store in z using conditional/ternary operators. Give the name of related header files (i) abs( ) (ii) atoi( ) (iii) setw ( ) (iv) isalpha ( ) What is the importance of main ( ) in a C++ program? How many bytes are required by the following (i) short int (ii)unsigned long (iii) long double (iv) signed char If we are having four variables named as a, b, c, d having values 4 ,7,12,4 respectively .Solve the related expression following (i) (a>b)&&(a= =d)||(c>d) (ii) (b<=a)&&(d>a)||(c=a) (iii) (True && ! False) || False What is typecasting? Give an appropriate example. What will be the output of following code segment: #include<iostream.h> #include<conio.h> void main() { int a,b; a=20; b=35; a++; cout<<a<<,; cout<<++a<<endl; cout<<b++ << ,; cout <<b; } What will be the possible output of the following function void Rprint() { randomise( ); int x=random(3)+1; 18 2

(g)

Q3.

(a)

(b)

(c)

2 2 2

(d) (e)

(f)

1*3

(g) (h)

2 2

Q4.

(a)

for(int i=0;i<=x;i++) cout<<i+2<<,; } (i) (ii) (iii) (iv) (b) 0,1,2,3,4,,5 1,2,3,4,5 2,3,4,5 2,3,4,5,6,

(c)

Convert following for loop into while loop:2 fact=1; sum=0; for(int i=1;i<10;i++) { for(int j=i;j>=1;j--) { fact=fact*j; } sum=sum+fact; fact=1; } Write a function to accept garment_code, cost of the garment as 3 input and calculate the bill amount after deducting DISCOUNT as per the following criteria: No. of Calls Amount Less than 500 no discount 501-2000 5% discount 2001-3000 10% discount 3001 and above 15% discount Find the output:(i) cout<< strcmp(computer,computer); (ii) cout<<isdigit(b); (iii) cout<<toupper(m); (iv) cout<<strlen(computer 123#5); (v) cout<<sqrt(pow(5, 2)); (vi) cout<<floor(7.8); 3

(d)

(e)

Write a user defined function Pattern_printing() which takes a 3 character and number of time to print as argument and print triangle . Example Input Char - * No of times 5 Output * ** *** **** ***** Find the errors in the following code segment { int a[5.5 ]={1,7,8,9,10}; sum=0;

Q5.

(a)

19

for (i=0;i<5;i++) if(a[i]%2==0) sum +=a(i); else sum = - a[t]; cout>>sum=>>sum>>endl; } (b) Consider the given code and answer question a to d 1 #include<iostream.h> 2 #include<conio.h> 3 void main() 4 { 5 int a,b; 6 cin>>a>>b; 7 int disp(int , int &); 8 cout<< disp(a,b); 9 } 10 int disp(int x, int &y) 11{ 12 int z=x+y; 13 return z; 14 } a. Identify the line number in which function prototype is given b. Identify the line number where the function disp() is called c. Identify the number and types of arguments d. What is the return type of the function disp() *4=2

(c)

Q6.

(a)

Write a user defined function lsearch( ) which takes three 3 parameters an integer array, size of array and element to be search and function return position of the element if the element is found and 0 if not found Example:Array {2,4,8,11,23,45,67,78,90} Element to search 11 Function should return 4 Consider the following code: 2 #define area(a) a*a void Aarea(int a) { return a*a; } void main ( ) { cout<<area(5+7); //Statement no 1 cout<<Aarea(5+7);// Statement no 2 } The output of Statement no 1 and Statement 2 will not be same. Give the output and the explanation. Write a user defined function in c++ which takes a string as parameter and it should also display total number of words in the 3

(b)

20

string and return number of words starting with A. Note:- Assuming that each word is separated by a single space. Example:String: An Apple A Day Keeps A Doctor away Output:8 Function should return 4 (c) Write a user defined function which takes one integer type 2-D array, no. of rows, no. of column as parameter and display product of the elements of each column Example: Array 1 2 4 7 2 3 1 0 3 5 6 9 Output Column no 1: 6 Column no 2:30 Column no 3:24 Column no 4:0 Q7. (a) What will be the output of the following code:struct Grocery { int I_no; char I_name[20]; float I_price; int I_qty; }; void main() { Grocery S[4]={{1,Bread,11.0,20}, {2, Butter,25.0,40}, {3,Cream,65,15}, {4,Jam,95.5,20}}; cout<<S[0].I_no; cout<<S[1].I_name[3]; cout<<S[2].I_qty; cout<<S[3].I_name; } Declare a structure Student with the following elements: Rollno Name DOB Marks Average integer type string type date type An array of float type to store marks in 5 subjects float *4=2 4

(b)

Write following user defined function in c++ to implement the above structure : 1 A function Read_student() which takes a structure object as a reference parameter and accept values of Rollno, Name,

21

DOB,Marks array 2. A function Calculate_Avg() which takes a structure object as a parameter and calculates the average marks of the student

22

SAMPLE QUESTION PAPER SET II COMPUTER SCIENCE (083) Class XI Marking Scheme
Time : 3 hours S.NO. Q1. Maximum Marks : 70 Marks 1 Sub Questions Part (a) Define Database Management System (DBMS). Name two database packages. Answer:A Database Management System is a package that can handle or manage bulk of stored data Example:- foxpro, Oracle, mysql, Ms- Acess mark for correct definition mark for correct examples. (b) Name any 2 anti virus software Answer:Quick heal Norton Kaspersky Or any other antivirus mark for each correct option (c ) Arrange the units of storage in descending order. TB, GB, PB,MB Answer:PB, TB, GB, MB 1 mark for correct order (d) Give the Full form of ASCII Answer:ASCII American Standard Code for Information Interchange 1 mark for correct conversion No mark f or partial conversion (e) Convert the following:(5) (45.54)10 =( ? )2 (6) (735)8 = (?)2 (7) (110100101111)2 = (?)10 (8) (A3F) 16 = (?)2 Answer:4 1 1 1

23

(1) (45.54)10 =(101101.010101)2 (2) (735)8 = (111011101)2 (3) (110100101111)2 = (3387)10 (4) (A3F)16 = (101000111111)2 1 marks for each CORRECT conversion (f) Differentiate between PS-2 port and serial port. Answer:PS/2 Port: - It stands for Personal System/2. It is most often used to plug in keyboard or mouse. Serial Port: - It transfers data serially one bit at a time. They are typically used to connect modem. 1 mark for each correct definitions mark for each correct example Q2 (a) Arrange in order:(vi) Coding of the program (vii) Design the program (viii) Testing the program (ix) Analyze the problem (x) Understand the problem Answer:(i) (ii) (iii) (iv) (v) 1 2

Understand the problem. Analyze the problem Design the program Coding of the program Testing the program

1 mark for correct order (b) Differentiate between /**/ and // Answer: /**/ Multiline Comment // Single Line Comment marks for each correct answers. (c ) How many times the following loop will be executed:for( int i=0;i<20;i+=2) Answer:10 times. 1 mark for correct answer (d) Identify the correct identifiers(any 2):(i). AS_G_D (ii) (iii) roll number (iv) (v) age123 (vi) 24 1 2wer S.I. rate 1 1

Answer:Correct Identifiers:AS_G_D, rate, age123 marks for any 2 correct identifier

(e)

What is the purpose of Indentation? Indent the following program: #include<iostream.h> void main() {int i=0; for (i=0;i<20;i++){ cout<<i; cout<<endl;} } Answer:Indentation makes the program more readable and presentable. Its main role is to highlight nesting eg groups of control statements. #include<iostream.h> void main() { int i=0; for (i=0;i<20;i++) { cout<<i; cout<<endl; } } 1 marks for correct purpose. 1 mark for indentation. if-else is used instead of switch-case in certain program segments, why? Explain giving examples. Answer:Switch-case is not suitable where you need to check the range Of values. For example:Grade allocation for percentage as shown below: 100 90 % GRADE A 91 70 % GRADE B switch case not suitable 71 50 % GRADE C < 50 % GRADE D

(f)

1 mark for correct explanation 1 mark for appropriate example. OR 2 marks for appropriate Example with its explanation. Identify the number of variables for input and output in the following case study:ABC bank wants to calculate Simple interest of a customer depending upon the principle value, rate of interest and time period. Note: -

(g)

25

Simple Interest = (Principal * Rate * Time period) /100 Answer: Three Input Variables. One Output Variable. 1 mark each for correct answer No mark to be deducted for giving name

Q3.

(a)

Identify the data types for the following (ii) a (ii) 0x234 Answer:(i)char (ii)int mark each for each correct data type

(b)

Write an expression to find the greater of two variables x, y and store in z using ternary operators Answer:z=(x>y)?x:y; 1 mark for correct answer No mark for any other answer

(c)

Give the name of related header files (i) abs( ) (ii) atoi( ) (iii) setw ( ) Answer:(i) math.h (ii) stdlib.h (iii) iomanip.h (iv) ctype.h mark for each correct answer.

2 (iv) isalpha ( )

2 (d) What is the importance of main ( ) in a program? Answer:Every c++ program execution begins at main ( ) and continues by sequentially executing the statements within main ( ). 1 mark for correct explanation How many bytes are required by the following (ii) short int (ii)unsigned long (iii) long double (iv) signed char Answer:(i) 2 Bytes (ii) 4 Bytes (iii) 10 Bytes mark for each correct answer. (f)

(e)

(iv) 1 Byte

If we are having four variables named as a, b, c, d having values ,7,12,4 respectively .Solve the related expression following (iv) (a>b)&&(a= =d)||(c>d) (v) (b<=a)&&(d>a)||(c=a) (vi) (True && ! False) || False Answer:(i) true or 1 (ii) false or 0 26

1X3

(iii)

true or 1

1 mark each for each correct answer (g) What is typecasting? Give an appropriate example. Answer:Explicit conversion of an operand from one data type to another is called type casting. Example : (float) (x+y/2) // assume x and y are int type It will evaluate the result to type float. 1 mark for correct definition 1 mark correct example (h) What will be the output of following code segment: #include<iostream.h> #include<conio.h> void main() { int a,b; a=20; b=35; a++; cout<<a<<,; cout<<++a<<endl; cout<<b++<< , ; cout<<b; } Answer:21,22 35, 3 1 mark for each correct line mark to be deducted for ignoring new line character What will be the possible output of the following function void Rprint() { randomise( ); int x=random(3)+1; for(int i=0;i<=x;i++) cout<<i+2<<,; } (v) 0,1,2,3,4,,5 (vi) 1,2,3,4,5 (vii) 2,3,4,5 (viii) 2,3,4,5,6, Answer: Option (iii) is correct because if the random number will generate values between 0 to 2 and value of x will vary from 1 to 3 so possible outputs can be (i) 2,3 (ii) 2,3,4 2 2

Q4.

(a)

27

(iii) 2,3,4,5 1 mark for correct answer 1 mark for correct reason (b) Convert following for loop into while loop:fact=1; sum=0; for(int i=1;i<10;i++) { for(int j=i;j>=1;j--) { fact=fact*j; } sum=sum+fact; fact=1; } Answer: fact=1; sum=0; int i=1; while(i<10) {j=i; while(j>=1) { fact=fact*j; j--; } sum=sum+fact; fact=1; i++ } 1 mark for each correct loop. (c) Write a function to accept cost of the garment as input and calculate the bill amount after deducting DISCOUNT as per the following criteria: No. of Calls Amount Less than 500 no discount 501-2000 5% discount 2001-3000 10% discount 3001 and above 15% discount void bill(int cost) { float Bill_amt,discount; if (cost<=500) discount=0; else if((cost>=501) && (cost<=2000)) discount=5/100*cost; else if((cost>=2001) && (cost <= 3000)) discount=10/100*cost; else discount=15/100*cost; 3 2

28

bill_amt=cost-discount; cout<<Bill Amount = Rs.<< bill_amt; } (d) Find the output:(i) cout<< strcmp(computer,computer); (ii) cout<<isdigit(b); (iii) cout<<toupper(m); (iv) cout<<strlen(computer 123#5); (v) cout<<sqrt(pow(5, 2)); (vi) cout<<floor(7.8); Answer: (i) (ii) (iii) (iv) (v) 3

0 0 M 14 5 7

mark for each correct answer (e) Write a user defined function Pattern_printing() which takes a character and number of time to print as argument and print lower triangle. Example Input Char - * No of times 5 Output * ** *** **** ***** Answer: Using for loop: void PatternPrinting(char x, int y) { for(int i=0;i<y;i++) {for(int j=0;j<=i;j++) cout<< x; cout<<endl;} } Using while and for loop: void Pattern_prinitng(char x, int y) { int i=0; whlie(i<y) {for(int j=0;j<=i;j++) cout<< x; cout<<endl; } i++; } 3

29

Using while loop only: void Pattern_prining(char x, int y) { int i=0; whlie(i<y) {int j=0; while(j<=i) {cout<< x; cout<<endl; j++; } i++;} } Or any other correct logic. mark for each correct loop. mark for correct function header. mark for declaring variables correctly. mark for displaying the character. mark for correct placement for newline character Find the errors in the following code segment { int a[5.5 ]={1,7,8,9,10}; sum=0; for (i=0;i<5;i++) if(a[i]%2==0) sum +=a(i); else sum = - a[t]; cout>>sum=>>sum>>endl; } Answer: Find the errors in the following code segment { int a[5 ]={1,7,8,9,10}; int sum=0; for (int i=0;i<5;i++) if(a[i]%2==0) sum +=a[i]; else sum -= a[i]; cout<<sum=<<sum<<endl; } mark each for identifying any 4 errors (b) Consider the given code and answer question a to d 1 #include<iostream.h> 2 #include<conio.h> 3 void main() 4 { 5 int a,b; 6 cin>>a>>b; 7 int disp(int , int &); *4=2

Q5.

(a)

30

8 cout<< disp(a,b); 9 } 10 int disp(int x, int &y) 11{ 12 int z=x+y; 13 return z; 14 } a. Identify the line number in which function prototype is given b. Identify the line number where the function disp() is called c. Identify the number and types of arguments d. What is the return type of the function disp() Answer:a. line no 7 b. line no 8 c. number of arguments 2, 1st argument - call by value and 2nd argument - call by reference d. int mark for each correct answer 3 (c) Write a user defined function lsearch( ) which takes three parameters an integer array, size of array and element to be search and function return position of the element if the element is found and 0 if not found Example:Array {2,4,8,11,23,45,67,78,90} Element to search 11 Function should return 4 Answer: int lsearch(int a[],int n, int e) { int f=0; for(int i=0; i<n;i++) { if(a[i]==e) f=i+1; } return f; } or int lsearch(int a[],int n, int e) { for(int i=0; i<n;i++) { if(a[i]==e) return i+1; } return 0; } Or any other correct logic.

31

Q6.

(a)

1 mark for correct loop. 1 mark for correct function header. mark for finding element (Correct if condition) mark for correct return statement Consider the following code: #define area(a) a*a void Aarea(int a) { return a*a; } void main ( ) { cout<<area(5+7); //Statement no 1 cout<<Aarea(5+7);// Statement no 2 } The output of Statement no 1 and Statement 2 will not be same. Give the output and the explanation. Answer:Aanswer of statement no 1 is 47 and statement no 2 is 144 Reason: Statement no 1 replace the text for the value as 5+7*5+7=47 Statement no 2 will pass the value to variable after solving the expression therefore it will pass 12

(b)

Write a user defined function in c++ which takes a string as parameter and it should also display total number of words in the string and return number of words starting with A. Note:- Assuming that each word is separated by a single space. Example:String: An Apple A Day Keeps A Doctor away Output:8 Function should return 4 Answer:int Count_str(char s[ ]) { int w=0;wa=0; for (int i=0;s[i]!=\0;i++) { if (s[i]== ) w++: if((s[i]== && s[i+1]==A) || (s[0]==A) wa++; } cout<<\n No of words << w+1; return wa; } Or any other correct logic.

32

mark for each correct loop. mark for correct function header. mark for finding element for counting word for counting word beginning with A mark for correct return statement 3 (c) Write a user defined function which takes one integer type 2-D array, no. of rows, no. of column as parameter and display product of the elements of each column Example: Array 1 2 4 7 2 3 1 0 3 5 6 9 Output Column no 1: 6 Column no 2:30 Column no 3:24 Column no 4:0 Answer:void array(int a[ ][5], int r, int c) { int p; for(int i=0; i<c;i++) { p=1; for(int j=0;i<r;i++) { p*=a[j][i]; } cout<<\n Coulmn no<<i+1<<:<<p; } Or any other correct logic. mark for each correct loop. 1 mark for correct function header. 1 mark for calculation and display of product

33

Q7.

(a)

What will be the output of the following code:struct Grocery { int I_no; char I_name[20]; float I_price; int I_qty; }; void main() { Grocery S[4]={{1,Bread,11.0,20}, {2, Butter,25.0,40}, {3,Cream,65,15}, {4,Jam,95.5,20}}; cout<<S[0].I_no; cout<<S[1].I_name[3]; cout<<S[2].I_qty; cout<<S[3].I_name; } Answer: 1t15Jam 2 marks for correct output mark for each correct part 1 t 15 Jam

*4=2

(b)

Declare a structure Student with the following elements: Rollno integer type Name string type DOB date type Marks An array of float type to store 5 elements Average float Write following user defined function in c++ to implement the above structure 1) A function Read_student() which takes a structure object as a reference parameter and accept values of Rollno, Name, DOB,Marks array 2) A function Calculate_Avg() which takes a structure object as a parameter and calculates the average marks of the student Answer:struct Date { int dd,mm,yy; }; struct Student { int Rollno; char Name[20]; Date DOB;

1+ 1+ 1 =4

34

float Mark[5],Average; }; void Input(Student &S) { cout<<\n Enter Rollno of student; cin>>S.Rollno; cout<<\n Enter Name of student; gets(S.Name); cout<<\n Enter the Date of Birth ; cin>>S.DOB.dd>>S.DOB.mm>>S.DOB.yy; for(int i=0;i<5;i++) { cout<<\n Enter marks in subject no<<i+1; cin>>S.Marks[i]; } } void Calculate_avg(Student &S) { float Sum=0; for(int i=0;i<5;i++) { Sum+=S.Marks[i]; } S.Average=Sum/5; } Or any other correct logic. mark to be deducted for each incorrect structure mark for correct function header for accepting rollno and name for accepting marks in loop mark for correct function header. for calculating sum in loop for calculating average

__________________________________ O___________________________________

35

You might also like