Computer Science Set 1

45
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. Topics Marks 1 Computer Fundamentals 10 2 Programming Methodology 10 3 Introduction to C++ 15 4 Programming in C++ 35 B. Weightage to different forms of questions S.No. Forms of Questions Marks for each questi ons Number of questi ons Total Marks 1 Very Short Answer questions(VSA) 1 14 14 2 Short answer questions-Type I (SA I) 2 15 30 3 Short answer questions-Type II (SA II) 3 6 18 4 Long answer questions (LA) 4 2 8 C. Scheme of Options There will be no overall choice. All questions are compulsory. D. Difficulty level of questions S.No. Estimated difficulty level Percentage of Marks 1 Easy 15% 2 Average 70% 3 Difficult 15% 1

description

computer Science sample papers

Transcript of Computer Science Set 1

Page 1: Computer Science Set 1

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. Topics Marks

1 Computer Fundamentals 102 Programming Methodology 103 Introduction to C++ 154 Programming in C++ 35

B. Weightage to different forms of questionsS.No. Forms of Questions Marks

for each question

s

Number of

questions

Total Marks

1 Very Short Answer questions(VSA) 1 14 142 Short answer questions-Type I (SA I) 2 15 303 Short answer questions-Type II (SA II) 3 6 184 Long answer questions (LA) 4 2 8

C. Scheme of OptionsThere will be no overall choice. All questions are compulsory.

D. Difficulty level of questions

S.No. Estimated difficulty level Percentage of Marks1 Easy 15%2 Average 70%3 Difficult 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.

1

Page 2: Computer Science Set 1

SAMPLE QUESTION PAPER SET ICOMPUTER SCIENCE (083)

Class – XI

BLUE PRINT

S.No. UNIT VSA(1 Mark)

SA I(2Marks)

SAII(3

Marks)

LA(4 Marks)

TOTAL(70

Marks)

1 COMPUTER FUNDAMENTALS   a) Software concepts & Operating Systemb) Number Systemc) Encoding, Microprocessor & Memory

Concepts

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

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

2 PROGRAMMING METHODOLOGYa) General Conceptsb) Problem Solving Methodology and

Technique

3(3)1(1)

4(2)2(1)

7(5)3(2)

3 INTRODUCTION TO C++ a) Getting Startedb) Data Types, Variables and Constantsc) Operators and Expressions

1(1)1(1)

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

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

4 PROGRAMMING IN C++             a) Flow of Controlb) Functions from header files(String.h,

ctype.h, math.h, stdlib.h)c) User Defined Functionsd) Structured Data Type : Arraye) User Defined data typesf) Structures

6(3)

2(1)

2(1)2(1)(HOTS)

9(3)

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

4(1)(HOTS)

9(3)6(3)

5(2)7(2)2(1)6(2)

14(14) 30(15) 18(6) 8(2) 70(37)

2

Page 3: Computer Science Set 1

SAMPLE QUESTION PAPER Set IComputer Science (083)

Class – XITime : 3 hours Maximum Marks : 70

General Instructions:-All the questions are compulsoryThe paper contain 7 QuestionsProgramming language used: C++

S.NO. Sub Part

Question Marks

Q1. (a)

(b)

(c)

(d)

(e)

(f)

Explain the need of Operating System.

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 = _____GB1 PB = ________ KB

2

1

(1*4=4)

1

1

1

Q2 (a)

(b)

(c)

(d)

(e)

(f)

(g)

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.

1

1

1

1

2

2

2

Q3. (a)

(b)

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.

2

2

3

Page 4: Computer Science Set 1

(c)

(d)

(e)

(f)

(g)

(h)

(i)

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;

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.

i) How ‘a’ is different from “a”?ii) Name << and >> operators.

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

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.

1*3=3

2

2

1

2

1

Q4. (a)

(b)

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 Amount0-50 Free51-100 20p per call101- 200 50 p per call201 and above 75p per callRent will be Rs 100 and is compulsory.

Give the output of the following program segment: char fname[50]= “ Charlie”;

3

2

4

Page 5: Computer Science Set 1

(c)

(d)

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;

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 ii) 1 2 3 4 5 (iii) 2 3 4 iv) 0 1 2

Also justify your answer.

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

2

3

Q5. (a )

(b)

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 }

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

2

4

5

Page 6: Computer Science Set 1

Studrec

rollno name address phoneno

houseno citystreetno

(c)

n is 6 Output : 3

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 8Output : Sum of left diagonal elements is 16

3

Q6. (a)

(b)

(c)

d)

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 loopint n=15, sume=0;for( int i=1; i<=n; i++){ if( i % 2 == 0 ) sume + = i ;}

2

2

3

3

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.

2

6

Page 7: Computer Science Set 1

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.ExampleInput : Length 1 m = 2 . cm = 60 Length 2 m -= 3, cm = 80

Output : Sum of lengths m = 6 cm = 40

4

7

Page 8: Computer Science Set 1

SAMPLE QUESTION PAPER SET IComputer Science (083)

Class – XIMARKING SCHEME

Time : 3 hours Maximum Marks : 70

General Instructions:-All the questions are compulsoryThe paper contain 7 QuestionsProgramming language used: C++

S.NO. Sub Part

Question Marks

Q1. (a)

(b)

(c)

(d)

(e)

(f)

Explain the need of Operating System.Ans:The need of OS is to perform :

i) Disk managementii) File managementiii) Memory managementiv) IO management

Name any two Utility Softwares.Ans:

i) Antivirusii) Disk Defragmentor

Convert the following :v) (213)10=( ?)2

vi) (1100.01)2= ( ?)8

vii) (AF)16 = (? ) 2

viii) (56)10 = (? )8

Ans:ix) (213)10=(11010101 )2

x) (1100.01)2= (14.2 )8

xi) (AF)16 = (10101111) 2

xii) (56)10 = ( 70)8

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 = _____GB1 PB = ________ KBAns: 1024 KB =10242 GB 1 PB = 10243 KB

2

1

(1*4=4)

1

1

1

Q2 (a) What is debugging ?Ans:

1

8

Page 9: Computer Science Set 1

(b)

(c)

(d)

(e)

(f)

(g)

Tracing and Rectifying the errors in a program.

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

What are the differences between an entry controlled loop and an exit 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 friendlyii) Meaningful variable names should be usediii) Optimum use of memoryiv) 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)

1

1

1

2

2

2

Q3. (a) 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 widthii) clrscr( ) – conio.h It is used to find the absolute value.iii) Pow() – math.h

2

9

Page 10: Computer Science Set 1

(b)

(c)

(d)

(e)

(f)

iv) Isupper() – ctype.h

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

(vi) int x; char ch = ’A’; x = ch; cout << x;Ans: 65

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.

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.

i) How ‘a’ is different from “a”?ii) Name << and >> operators.

Ans: i)1) ‘a’ is character constant and “a” is string constant2) Size of ‘a’ is 1 byte and size of “a” is 2 bytes3) ‘a’ contains a single character ‘a’ and “a” contains two

characters ‘a’ and ‘\0’( Any two )

Ans .ii) Extraction and insertion opperators

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

int a; long b;

2

1

1*3=3

2

1

1

10

Page 11: Computer Science Set 1

(g)

(h)

Ans:i) 2 bytesii) 4 bytes

Solve the following:

i) 8 / 2 + 9 * 10 % 2 Ans: 4

ii) a && b || a <= b if a = 10, b = 5 Ans: 1

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

2

1

Q4. (a)

(b)

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 Amount0-51 Free51-101 20p per call101- 200 50 p per call201 and above 75p per callRent 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;}

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

3

2

11

Page 12: Computer Science Set 1

(c)

(d)

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 ii) 1 2 3 4 5 (iii) 2 3 4 iv) 0 1 2

Also justify your answer.Ans:

1 2 3 4 5As 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.

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) }

2

3

Q5. (a ) 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;

2

12

Page 13: Computer Science Set 1

(b)

(c)

increase(x, y, ::x); cout<<’\n’<<::x<<’\t’<<x<<’\t’<<y }

Ans:6 11 1111 5 10

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 : 3Ans: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;}

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 8Output : Sum of left diagonal elements is 16Ans: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;}

4

3

Q6. (a)

(b)

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;

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

2

13

Page 14: Computer Science Set 1

(c)

d)

{ 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 loopint 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 ;}

3

3

14

Page 15: Computer Science Set 1

Studrec

rollno name address phoneno

houseno citystreetno

Q.7 a)

b)

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.

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

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.ExampleInput : 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;}

2

4

15

Page 16: Computer Science Set 1

SAMPLE QUESTION PAPER SET IICOMPUTER SCIENCE (083)

Class – XI

BLUE PRINT

S.No. UNIT VSA(1 Mark)

SA I(2Marks

)

SAII(3

Marks)

LA(4 Marks)

TOTAL(70

Marks)

1 COMPUTER FUNDAMENTALS   a) Software concepts & Operating Systemb) Number Systemc) Encoding, Microprocessor & Memory

Concepts

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

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

2 PROGRAMMING METHODOLOGYa) General Conceptsb) Problem Solving Methodology and

Technique

1(1)3(3)

2(1)4(2)

3(2)7(5)

3 INTRODUCTION TO C++a) Getting Startedb) Data Types, Variables and Constantsc) Operators and Expressions

1(1)1(1)

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

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

4 PROGRAMMING IN C++             a) Flow of Controlb) Functions from header files(String.h,

ctype.h, math.h, stdlib.h)c) User Defined Functionsd) Structured Data Type : Arraye) User Defined data typesf) Structures

4(2)2(1)

2(1)2(1)2(1)HOTS

3(1)3(1)

3(1)6(2) 4(1)HOTS

4(1)HOTS

7(3)5(2)

3(1)12(4)2(1)6(2)

14(14) 30(15) 18(6) 8(2) 70(37)

16

Page 17: Computer Science Set 1

SAMPLE QUESTION PAPER SET II COMPUTER SCIENCE (083)

Class – XITime : 3 hours Maximum Marks : 70

General Instructions:-All the questions are compulsoryThe paper contain 7 QuestionsProgramming language used: C++

S.NO. Sub Part

Questions Marks

Q1. (a)

(b)

(c )

(d)

(e)

(f)

Define Database Management System (DBMS). Name two database packages.

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.

1

1

1

1

1X4

2

Q2 (a)

(b)

(c )

(d)

(e)

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) 2wer (iii) roll number (iv) S.I.(v) age123 (vi) rate

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;

1

1

1

1

2

17

Page 18: Computer Science Set 1

(f)

(g)

cout<<endl;} }

If–else is used instead of switch-case in certain program 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

2

2

Q3. (a)

(b)

(c)

(d)

(e)

(f)

(g)

(h)

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

1

1

2

2

2

1 * 3

2

2

Q4. (a) What will be the possible output of the following functionvoid Rprint(){ randomise( ); int x=random(3)+1;

2

18

Page 19: Computer Science Set 1

(b)

(c)

(d)

(e)

for(int i=0;i<=x;i++) cout<<i+2<<”,”;}

(i) 0,1,2,3,4,,5(ii) 1,2,3,4,5(iii) 2,3,4,5(iv) 2,3,4,5,6,

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;}Write a function to accept garment_code, cost of the garment as input and calculate the bill amount after deducting DISCOUNT as per the following criteria:No. of Calls AmountLess than 500 no discount 501-2000 5% discount2001-3000 10% discount3001 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);

Write a user defined function Pattern_printing() which takes a character and number of time to print as argument and print triangle . Example

Input Char - ‘*’No of times 5Output***************

2

3

3

3

Q5. (a) Find the errors in the following code segment{ int a[5.5 ]={1,7,8,9,10}; sum=0;

2

19

Page 20: Computer Science Set 1

(b)

(c)

for (i=0;i<5;i++) if(a[i]%2==0) sum +=a(i); else sum = - a[t]; cout>>”sum=”>>sum>>endl;}

Consider the given code and answer question a to d1 #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 argumentsd. What is the return type of the function disp()

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 foundExample:-Array {2,4,8,11,23,45,67,78,90} Element to search 11Function should return 4

½*4=2

3

Q6. (a)

(b)

Consider the following code: -#define area(a) a*avoid 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

2

3

20

Page 21: Computer Science Set 1

(c)

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 awayOutput:8Function should return 4

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 72 3 1 03 5 6 9OutputColumn no 1: 6Column no 2:30Column no 3:24Column no 4:0

4

Q7. (a)

(b)

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 integer typeName string typeDOB date typeMarks An array of float type to store marks in 5 subjectsAverage 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,

½ *4=2

4

21

Page 22: Computer Science Set 1

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

Page 23: Computer Science Set 1

SAMPLE QUESTION PAPER SET II COMPUTER SCIENCE (083)

Class – XIMarking Scheme

Time : 3 hours Maximum Marks : 70

S.NO. Sub Part

Questions Marks

Q1. (a)

(b)

(c )

(d)

(e)

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 dataExample:- foxpro, Oracle, mysql, Ms- Acess

½ mark for correct definition½ mark for correct examples.

Name any 2 anti virus software

Answer:- Quick healNortonKasperskyOr any other antivirus

½ mark for each correct option

Arrange the units of storage in descending order.TB, GB, PB,MB Answer:-PB, TB, GB, MB

1 mark for correct order

Give the Full form of ASCII

Answer:-ASCII – American Standard Code for Information Interchange

1 mark for correct conversionNo mark f or partial conversion

Convert the following:- (5) (45.54)10 =( ? )2

(6) (735)8 = (?)2

(7) (110100101111)2 = (?)10

(8) (A3F) 16 = (?)2

Answer:-

1

1

1

1

4

23

Page 24: Computer Science Set 1

(f)

(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

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

2

Q2 (a)

(b)

(c )

(d)

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) Understand the problem.(ii) Analyze the problem(iii) Design the program(iv) Coding of the program(v) Testing the program

1 mark for correct order

Differentiate between /*………*/ and //

Answer: -/*………*/ Multiline Comment// Single Line Comment

½ marks for each correct answers.

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

Identify the correct identifiers(any 2):-(i). AS_G_D (ii) 2wer (iii) roll number (iv) S.I.(v) age123 (vi) rate

1

1

1

1

24

Page 25: Computer Science Set 1

(e)

(f)

(g)

Answer:-Correct Identifiers:-AS_G_D, rate, age123

½ marks for any 2 correct identifier

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 A91 – 70 % GRADE B switch – case not suitable71 – 50 % GRADE C < 50 % GRADE D

1 mark for correct explanation1 mark for appropriate example. OR2 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: -

2

2

2

25

Page 26: Computer Science Set 1

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

Q3. (a)

(b)

(c)

(d)

(e)

(f)

Identify the data types for the following(ii) ‘a’ (ii) 0x234

Answer:-(i)char(ii)int½ mark each for each correct data type

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 answerNo mark for any other answer

Give the name of related header files(i) abs( ) (ii) atoi( ) (iii) setw ( ) (iv) isalpha ( )

Answer:-(i) math.h(ii) stdlib.h(iii) iomanip.h(iv) ctype.h½ mark for each correct answer.

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 (iv) 1 Byte

½ mark for each correct answer.

If we are having four variables named as a, b, c, d having values 4 ,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) || FalseAnswer:-(i) true or 1(ii) false or 0

1

1

2

2

2

1X3

26

Page 27: Computer Science Set 1

(g)

(h)

(iii) true or 1

1 mark each for each correct answer

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 typeIt will evaluate the result to type float.1 mark for correct definition1 mark correct 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;}

Answer:-21,2235, 31 mark for each correct line½ mark to be deducted for ignoring new line character

2

2

Q4. (a) What will be the possible output of the following functionvoid 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

27

Page 28: Computer Science Set 1

(b)

(c)

(iii) 2,3,4,51 mark for correct answer1 mark for correct reason

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.

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 AmountLess than 500 no discount 501-2000 5% discount2001-3000 10% discount3001 and above 15% discountvoid 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;

2

3

28

Page 29: Computer Science Set 1

(d)

(e)

bill_amt=cost-discount; cout<<”Bill Amount = Rs.“<< bill_amt;}

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) 0(ii) 0(iii) M(iv) 14(v) 5

7

½ mark for each correct answer

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 5Output***************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

3

29

Page 30: Computer Science Set 1

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

Q5. (a)

(b)

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

Consider the given code and answer question a to d1 #include<iostream.h>2 #include<conio.h>3 void main()4 {5 int a,b;6 cin>>a>>b;7 int disp(int , int &);

2

½ *4=2

30

Page 31: Computer Science Set 1

(c)

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 argumentsd. What is the return type of the function disp()

Answer:-a. line no 7b. line no 8c. number of arguments 2, 1st argument - call by value and 2nd

argument - call by referenced. int

½ mark for each correct answer

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 foundExample:-Array {2,4,8,11,23,45,67,78,90} Element to search 11Function 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;} orint 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.

3

31

Page 32: Computer Science Set 1

1 mark for correct loop.1 mark for correct function header.½ mark for finding element (Correct if condition)½ mark for correct return statement

Q6. (a)

(b)

Consider the following code: -#define area(a) a*avoid 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 144Reason:Statement no 1 replace the text for the value as 5+7*5+7=47Statement no 2 will pass the value to variable after solving the expression therefore it will pass 12

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 awayOutput:8Function 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.

2

3

32

Page 33: Computer Science Set 1

(c)

½ 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

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 columnExample:Array 1 2 4 72 3 1 03 5 6 9OutputColumn no 1: 6Column no 2:30Column no 3:24Column 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

3

33

Page 34: Computer Science Set 1

Q7. (a)

(b)

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:1t15Jam2 marks for correct output½ mark for each correct part 1t15Jam

Declare a structure Student with the following elements:Rollno integer typeName string typeDOB date typeMarks An array of float type to store 5 elementsAverage 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 array2) 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;

½ *4=2

1+1 ½ +1 ½ = 4

34

Page 35: Computer Science Set 1

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