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

Delhi Public School Navi Mumbai Revision Examination 2016-17. I. Answer The Following Questions

This document contains revision examination questions from Delhi Public School in Navi Mumbai for the 2016-17 school year. It includes questions in the following categories: 1) Conversions between number systems like binary, octal, decimal, and hexadecimal. 2) Questions about computer programming concepts like data types, operators, functions, arrays, and structures. 3) Problems involving writing and analyzing code snippets to find outputs or syntax errors. An answer key is provided with explanations for the questions.

Uploaded by

Shrey Pandit
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Delhi Public School Navi Mumbai Revision Examination 2016-17. I. Answer The Following Questions

This document contains revision examination questions from Delhi Public School in Navi Mumbai for the 2016-17 school year. It includes questions in the following categories: 1) Conversions between number systems like binary, octal, decimal, and hexadecimal. 2) Questions about computer programming concepts like data types, operators, functions, arrays, and structures. 3) Problems involving writing and analyzing code snippets to find outputs or syntax errors. An answer key is provided with explanations for the questions.

Uploaded by

Shrey Pandit
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

DELHI PUBLIC SCHOOL

NAVI MUMBAI
REVISION EXAMINATION 2016-17.

I. Answer the following questions [2 x 6 = 12]

1. Give the difference between


a. Low level and High level language
b. RAM and ROM.
2. Give any two features of 2nd generation computers
3. Define corrective and preventive maintenance.
4. Rewrite the following program to adhere to pretty printing.
int main(){ for(int i=0;i<=10;i++)if(i%2)cout<<i<<’ ‘;else cout<<i+2; return 0;}
5. When a message “abnormally terminated” is displayed what type of error is encountered.
Explain the error type with an example.
6.Define robustness and guard code.

II. Convert the following [2 x 5 = 10]


a. A47D 16  OCTAL
b. 862.363 10  BINARY
c. 473.72 8  DECIMAL
d. 23343 10  HEXADECIMAL
e. 101011011.11 2  DECIMAL
III. Answer the following questions [2 x 6 = 12]
1. Evaluate the following if k =10 intially for both cases.
a) (2 * k++) % 7 ______________________________
b) --k + 4*k + 6 ______________________________

2. What is the use of setw( ) manipulator. Explain with example.


3.What will be the output of the following if the input is
(i) a (ii) b (iii) d (iv) h

char ch , out[10]="\0";
cin>>ch;
switch(ch)
{
case 'a' : strcat(out,"a");
case 'b' : strcat(out, "b");
case 'c' : strcat(out,"c");
break;
case 'd' : strcat(out,"d");
default : strcat(out,"Not abcd");
break; }
4.Explain the sizeof( ) operator with an example
5.What is typedef? Explain with example.
6.What is a macro. Explain with an example.

IV. Give the output for the following code snippets. Assume all header files are
included.

b. void main( ) [1]


{ int w = -3;
w != ( w = abs(w)) ? cout<<”zero”: cout<<”one”;
}

c. struct three_d [3]


{ int x,y,z ;};
void movein( three_d &t , int step = 1)
{
t.x += step;
t.y -= step;
t.z += step; }
void moveout( three_d &t , int step = 1)
{
t.x -= step;
t.y += step;
t.z -= step;
}
void display( three_d t2)
{ cout<<t2.z<<","<<t2.x<<","<<t2.y<<endl; }
void main()
{ three_d t1 = {10,20,5}, t2 = {30,10,40};
movein(t1);
moveout(t2,5);
display(t1);
display(t2);
movein(t2,10);
cout<<t2.x<<","<<t2.y<<","<<t2.z;
}
d. Observe the following program and find out which output(s) will not be expected. Justify your
answer. What will be the minimum and maximum value assigned to the variable turn. [2]
void main()
{ randomize();
int game[ ]={10,16},p;
int turn = random(2) + 5;
for(int t=0;t<2;t++)
{ p=random(2);
cout<<game[p]+turn<<"#";}}
e.
int x=5; [2]
int mod(int temp)
{ if (temp % 5 ==0)
x+=temp;
else
temp +=x+3;
return temp;
}
void doupd(int m , int &n)
{ int x=5;
x++;
m = n + :: x;
if(n>30)
n=mod(n);
else
n = (mod(n),m);
cout<<m<<":"<<n<<":"<<x<<":"<<::x<<endl;}

void main()
{int x=5 , y=22;
doupd(::x,y);
cout<<x<<":"<<y<<":"<<::x<<endl;
doupd(y,x);
cout<<x<<":"<<y<<":"<<::x<<endl;
}
f. [2]
void main()

{ int y=0;

while(y<=10)

{ int x=1;

do{x++;

if(y%x= =0) cout<<"*";

if(x%3==2) cout<<"#";

}while(x<3);

y+=6; cout<<"%";

}}

g. [2]
void main()

{ int a[ ]={18,12,45,54,71},i;

for(i=0;i<4;i++)

if(!(a[i]%9))

a[i+1]=a[i]*2;

else
a[i]=a[i+1];

for(i=0;i<5;i++)

cout<<a[i]<<"@";}

V Identify the syntax errors in the following codes. Rewrite the corrected code
and underline the corrections. [2 + 2]
a. #define pi = 3.1451
#define circlearea(int x) ( pi *x*x);
void main( )
{ float area; int r;
cin>>r; area = circlearea(x);
cout<<area;
}

b. main( )
{struct bank
{ char cname[25] ; char ccode[5];
char loantype[15] ;
float depamt;
}customer;
Customer cust; strcpy(cname , “Raju”);
cust.ccode = “C105”; cust.depamt = 25000 ;
customer = cust;
cout<<customer.ccode<<bank.cname<<cust.depamt;
}

VI Do the following
A. Write a program to accept a single character from the user. [2]
Use a SINGLE NESTED CONDITIONAL(TERNARY) OPERATOR to check for the following
 If digit is entered display “DIGIT”
 If alphabet is entered display the alphabet in uppercase
 For any other entry display “SYMBOL”
B. Write a program to read a line of text in a string. Display
 total number of words and
 total number of characters in the text. [3]

C. Pivot index of an array is an index number where the sum of numbers on the left (from that
point ) is equal to the sum of numbers on the right(from that point).
Example if the array is
3 1 2 41 0 6

then the PIVOT INDEX IS 3 [3]

Write a function checkpivot(int a[ ]) that would accept a one dimensional integer array as
argument and find the pivot index. If there is a pivot index the index number should be displayed
else the message “NO PIVOT INDEX FOUND” should be displayed.

E. In a 2D array if each descending diagonal from left to right has the same number then the
matrix is called a TOEPLIZ matrix. Example : [4]

6 7 8 9 2

4 6 7 8 9

1 4 6 7 8

0 1 4 6 7
Write a function TZ( ) that would accept a 2 dimensional integer array , its total rows and its total
column as arguments. The function checks if the given array is a TOEPLIZ matrix or not. If yes
the function should return 1 else the function should return -1. Write main( ) to accept values into
the array , call the function and display appropriate message after checking the returned value.

F. An array stores details of 25 students(rollno, name, marks in 5 subjects). Write a program to


create and accept values into the array. Display the complete records of students who have failed
in 3 or more subjects. [4]

ANSWER KEY
I
1. a. Low level language are written in binary language whereas a HLL should be processed so
as to make it understandable to the computer. Language processors convert HLL to machine
language.
b. RAM is volatile while ROM is nonvolatile.

2. Transistors replaced vacuum tubes, core memory developed, First operating systems
developed, programming in machine and assembly language, magnetic tapes and disks were
used.
3. Corrective maintenance – When a program after completion is put to operations some errors
due to unexpected situations ,untested areas may occur. this is fixed and this type of maintenance
is corrective maintenance.
Preventive maintenance - If possible errors could be anticipated before they actually occur
maintenance could bedone to avoid them. This is preventive maintenance.
4.
int main()
{
for(int i=0 ; i<=10 ; i++)
if(i%2)
cout<<i<<’ ‘;
else
cout<<i+2;
return 0;
}
5. The type of error is runtime error. Errors that occur during the execution of a program are
runtime errors.Eg : infinite loop or wrong value(of different data type) is entered.

II CONVERSIONS

a. 1221758
b. 1101011110.010111002
c. 315.9062510
d. 5b2f16
e. 347.7510

III
ANSWER THE FOLLOWING

1.

2. setw ()
3. a  abc
b  bc
d  dNotabcd
h  Notabcd

OUTPUTS

b. one
c.

d. random
e.
f.
*#*%*#*%
g.
18@36@72@144@288@

A. CONDITIONAL OPERATOR
void main()
{char ch;
cin>>ch;
isalpha(ch)? cout<< (char)toupper(ch) : isdigit(ch) ? cout<<"Digit" : cout<<"Symbol";
}

B.
C.PIVOT INDEX
void main()
{int a[]={1,2,3,4,0,6} ,sumj=0,sumk=0;
for(int i=0;i<6;i++)
{sumj=0;sumk=0 ;
for(int j=0;j<i;j++)
sumj += a[j];
for(int k=i+1;k<6;k++)
sumk+=a[k];
if(sumj==sumk)
{cout<<i; break;}
}
if(i==6)
cout<<"No pivot";}

D. ANAGRAM
void main()
{char a[20],b[20];
gets(a); gets(b);
int i=0,j=0,x=0,y=0,flag=0;
while(a[i] !='\0')
{ char d = a[i]; x=y=0;

for(j=0;j<strlen(a);j++)
{ if(a[j]==d)
x++;
if (b[j]==d)
y++;
}
if(x!=y)
{flag=1;break;}
i++;
}
if(flag==1)
cout<<"No";
else
cout<<"yes";
}
E.TOEPLIZ MATRIX CHECK
void main()
{int a[4][5]={{6,7,8,9,2},{4,6,7,8,9},{1,4,6,7,8},{0,1,4,6,7}} ;
int r=4,c=5,flag=0;
for(int i=0;i<r-1;i++)
{ for(int j=0;j<c-1;j++)
{ if(a[i][j] != a[i+1][j+1])
{ flag = -1; }
}
}
if(flag==0)
cout<<"Toepliz";
else
cout<<"No";
}

You might also like