0% found this document useful (0 votes)
34 views

Computer Science 15

Uploaded by

anirudhjindal032
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Computer Science 15

Uploaded by

anirudhjindal032
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Roll No.

_________________ Code : 112015-083-A

Please check that this question


paper contains 7 questions and 7
printed pages.

CLASS-XI
COMPUTER SCIENCE
Time Allowed : 3 Hrs. Maximum Marks : 70
General Instructions :
All the questions are compulsory.
The paper contains 7 questions.
Programming language used : C++

S. Sub Question Marks


No. Part
1. (a) How is data different from information ? (1)
(b) What do you understand by GUI ? (1)
(c) Differentiate between the following : (2+2)
(i) Virus and Worm
(ii) Utility software and Application software
(d) Convert the following : (4)
(i) (27.625)10 = (?)2
(ii) (A42)16= (?)8
(iii) (23.25)8 = (?)10
(iv) (11100.1010)2= (?)16

2. (a) Identify the type of errors (Syntax, Logical, Run-time) :

(i) int a=10; (1)


int b=20;
c=b-a;
cout<<”sum of”<<a<<”and”<<b<<”=”<<c;
(ii) a=7/0; (1)
(iii) ra+one=mov; (1)

(b) Give an example of single line comment and multiline comment each. (2)

CSc 1
(c) How many times the following loops will be executed : (1+1+1)
(i) for(int i=1;i<=10;i++)
{cout<<i++;}
(ii) int i=11;
while(i<11)
(cout<<i;}
(iii) int i=5;
do {
cout<<i;
} while(i<1);
(d) A storekeeper wants to keep track of his inventory. He wants to give
each item a code no; and a name, He also wants to store the price of
each item alongwith quantity in stock.
Suggest suitable variable names and their data types. (2)
(e) What is an infinite loop ? (1)
(f) What is a program ? (1)

3. (a) Find out the errors in the following C++ statements : (2)
(i) cout<<”a=”a;
(ii) for (x=±1; x < 10; x++)
(iii) x = + 2;
(iv) break=x*y
(b) Observe the following C++ code carefully and rewrite the same after
removing all the syntax error(s) present in the code. Ensure that you
underline each correction in the code. (2)
Important Note:
- All the desired header files are already included, which are required
to run the code.
- Correction should not change the logic of the program.
#define Change(A,B) 2*A+B;
void main()
{
Float X, Y,F;
cin>>X>>Y;
F=Change[X, Y];
cout<<”Result:”<<F<endline;
}

CSc 2
(c) Observe the following C++ code and write the name(s) of the header
file(s), which will be essentially required to run it in a C++ compiler : (2)
void main()
{
float Area, Side;
cin>>Area;
Side=sqrt(Area);
cout<<”One Side of the Square:”<<Side<<endl;
}
(d) Determine the number of bytes required to store (2)
BOOK_NO integer type
BOOK_TITLE 20 Characters
PRICE float (price per copy)
Type char
(e) Construct logical expressions to represent the following conditions : (2)
(i) salary is in the range 8000 to 10000
(ii) ch is an uppercase letter
(iii) value is not in the range 10 and 20
(iv) a is an odd number
(f) Write a c++ program to input a number and print its factorial. (2)
(g) What is difference between ‘/’ and ‘%’ operators in c++ ? Explain with
example. (2)

4. (a) Find the output of the following program : (3)


#include <iostream>
void display(charc= ’*’, intn= 1);
int main() {
display();
display(’#’);
display(’$’, 5);
return 0;
}
void display(char c, int n) {
for(int i = 1 ; i <=n; ++i) {
cout<<c;
}
cout<<endl;
}
CSc 3
(b) What will be the output ? All header files are present. (3)
void main ()
{ char title [] = ”Academic”
int h=strlen (title);
for (int j = 0; j < h; j++)
{ if (j % 3 = = 0)
title [j] = title[j+1];
else
title [j] = ’*’;
}
cout << ”title is: ”<c title;
}

5. (a) The following program is used to find the reverse of a number. Some
statements are missing in it. Fill in the missing statements. (3)
void main()
{
int n, rem, rev =___;
cin>>n;
while(_________)
{
rem =__________;
rev =___________;
n =___________;
}
cout<<___________;
}

(b) Kavya is playing a game that generates a set of 4 random numbers. Help
her to identify the correct option(s) from the options given below so that
she wins the game. Justify your answer. (2)
#include<iostream.h>
#include<stdlib.h>
const int INIT=15;
void main()
{
randomize();
int p=5,n;
for(int i=1;i<=4;i++)
{
n=INIT+random(p);
cout<<n<<’:’;
}
}
(i) 19:16:15:18: (ii) 14:18:15:26:
(iii) 19:16:14:18: (iv) 19:16:15:16:
CSc 4
(c) Rewrite the following code using “switch-case” selection control (3)
char ch;
cout<<”\n Enter the grade from A- E”;
cin>>ch;
if(ch == ‘A’ || ch == ‘B’)
cout<<”Excellent”;
else if(ch == ‘C’)
cout<<”Good”;
else if(ch == ’D’)
cout<<” Average”;
else if (ch==’E’)
cout<<”Work Hard”;
else
cout<<”Wrong Choice”;char ch;

6. (a) Write a program in C++ to shift all positive elements of an array to the
left and all negative elements to the right. (3)
E.g.
If the array is
A : 2, 4, –1, 6, –7, –3, 8, 10
Then the resultant array should be
B : 2, 4, 6, 8, 10, –1, –7, –3

(b) Write a program in C++ which accepts a string, counts number of digits
and display it. For example : (4)
Example
Input String : I earned 34 points and Arnav scored 8.
Output : 3
The code should be “indented” properly.

(c) Read the following program and answer question (i) and (ii) : (2+2=4)
#include<iostream.h>
void swap1 (int a,int b)
{

CSc 5
int temp;
temp=a;
a=b;
b=temp;
}
void swap2(int &a,int &b)
{
int temp;
temp=a;
a=b;
b=temp;
}
void main()
{
int x=2;
int y=3;
swap1 (x,y);
cout<<x<<”,”<<y<<endl; //statement 1
swap2(x,y);
cout<<x<<”,”<<y<<endl; //statement 2
}
(i) What will be the output of statement 1 and statement 2 ? Justify
your answer.
(ii) Identify the type of parameter (actual and formal) from the
following parameters. Give reason to justify your answer.
(d) Write a function in c++ to print the product of each column of a two
dimensional integer array passed as the argument of the function : (3)
Explain : If the 2-D array contains :
2 3 1
6 1 6
1 5 2
6 4 7
Then the output should appear as :
Product of column 1 = 72
Product of column 2 = 60
Product of column 3 = 84

CSc 6
7. (a) Give the output of the following program (Assuming that all required
header files are included in the program) (2)
#include<iostream.h>
struct TD
{ int x,y,z; };
void MvIn(TD &P, int step)
{
P.x+=step;
P.y–=step;
P.z+=step;
}
void main()
{
TD ob={ 15,25,5};
MvIn(ob,3);
cout<<ob.x<<’,’<<ob.y<<’,’<<ob.z<<endl;
}
(b) Consider the following structure of date (2+2=4
struct Date
{
int dd,mm,yy;
};
Write a function int Compare_date(date d1,date d2) which takes 2
dates variables as parameter and returns 1 if the dates are same
and 0 if the dates are different or
(Assuming both the dates are valid)
E.g. dd mm yy
If value of 1st date variable is 2 10 2014
And value of 2nd date variable is 4 12 2014
The function should return :0
st
If value of 1 date variable is 4 12 2014
nd
And value of 2 date variable is 4 12 2014
The function should return :1
Write a program to declare 2 date variables. Accept values in 2
date variables and invoke the function Compare_date().

CSc 7

You might also like