Page 673 - Computer science 868 Class 12
P. 673
Question 2..
(i) Convert the following infix notation to postfix form. ( A / B + C ) / ( D * ( E − F ) [2]
(ii) An array ARR[ −4 …..6, −2…..12] , stores elements in Row Major Wise, with the address ARR[2][3] as 4142. If each element
requires 2 bytes of storage, find the Base address. [2]
(iii) The following functions are a part of some class:
void Try(char ch[],int x)
{ System.out.println(ch); char temp;
if ( x<ch.length/2)
{ temp=ch[x];
ch[x]= ch[ch.length-x-1];
ch[ch.length-x-1] = temp;
Try(ch,x+1);
} }
void Try1(String n)
{ char c[]=new char[n.length()];
for(int i=0;i<c.length;i++)
c[i] = n.charAt(i);
Try(c,0);
}
(a) What will the output of Try( ) when the value of ch[]={‘P’, ‘L’,‘A’, ‘Y’} and x=1? [2]
(b) What will the output of Try1( ) when the value of n=”SKY”? [1]
(iv) The following function is a part of some class which computes and returns the value of a number ‘p’ raised to the power ‘q’
(pq). There are some places in the code marked by ?1? , ?2? , ?3? which must be replaced by an expression / a statement so
that the function works correctly.
double power ( double p , int q )
{ double r = ?1? ;
int c = ( q<0 ) ? -q : q ; if ( q == 0)
return 1 ;
else
{ for (int i = 1; i <= c ;?2?, i++);
return (q>0)? r : ?3?;
}
}
(a) What is the expression or statement at ?1? [1]
(b) What is the expression or statement at ?2? [1]
(c) What is the expression or statement at ?3? [1]
671
Sample Paper 671

