(Revision of C++)  XII COMPUTER SCIENCE 
MARKS-20x2=40      SET-CS02
Q1.What will be the sizes of following constants :  ‘\a’ , “\a” , “Ra\\o\ne\’s\t”  , “\”RAM\””    ?
Q2.What are the predefined stream objects in I/O library?
Q3.Point out the errors in the following program :
                  int main ()
                   {
                            cout << “Enter variable “ ;
                            cin  >> var ;
                            sqrs = var * var;
                           cout << “ The square is “
                                    << sqrs;
Q4.Which of the following are valid character constants in C++ ?
       ‘C’  , ABC’  , “ABC” , my , ‘main’s’ , ‘ ‘’ ‘ , ‘char,   ‘\\’
Q5. Given the following code fragment
        int ch = 64;
        cout << ++ch << “\n” << ch<<”\n”;
  1. What will be the output?
  2. What is the effect of replacing ++ch with ch+1;
Q6.What will be the result of following expressions if i=10 initially ?
(i)                  ++i<=10      (ii)  i++ <= 10  (iii) ++i = i++  (iv) +i++ = 5 (v) +++i<=10
Q7. Given the following two definitions:
Unsigned int u1=0, u2=7;
What is the result of each of the following expressions?
(i)                  u1&&u2     (ii) u1||u2  (iii) !u1 (iv) !!u1  (v) !(-5)


Q8.         Given the following set of identifier s?
                char ch ;
                short sh ;
                int intval ;
                long longval ;
                float fl ;
Identify the data type of the following expressions
(a)    ‘a’-3       (b)intval*longval-ch        (c)fl+longval/sh
Q9.         What output will the following code fragment produce?
                int val , res, n= 1000;
                cin >> val;
                res=n=val>1750? 400:200;
                cout<< res ;
(I)                 If the input is 2000
(II)               If the input is 1000
(III)             If the input is 500

Q10.Using the declaration of Q.8 , identify which of the following assignments are unsafe (where there    may be loss of data)
(a)    Sh=intval             (b)intval=longval              (c) sh=ch
Q11.       What is the output of the  following code snippet?
                main ()
                {              int I = j =k =0 ;             Cout<<I<<j<<k;       }
Q12.       Evaluate the following expressions:

(I)                 x-y < z && y+z > x || x-z <=y-x+z              if x= 4, y= 7 and z=10?
(II)               (y)&& (y-z)|| ! (2y+z-x)                if x=13, y=14,     and z= 15
Q13.Evaluate the following c++ expressions where a,b,c are integers and d,f are floating point numbers. The value of a=5 , b=3 and d =15
(a)    f = a+b/a
(b)   c=d*a+b
(c)    c=(a++)*d+a
(d)   f=(++b)*b-a
(e)   c=a-(b++)*(--a)
Q14. Predict the output of the following codes :
(i)                  if(!3)
{
   cout<<”Tricky1\n”;
}
cout<<”YES”;
(ii)
If(0)
cout<<”Tricky2\n”;
cout<<”Tricky3\n”;
(iii)
                    If(!0)
                         cout<<”Tricky4\n”;
                          cout << “No??”;

Q15. What will be the output when the input is (a) ‘A’ (b) ‘C’ (c) ‘D’ (d) ‘F’  (e) 65 (f) 66 ?
                  
[PART-1]
cin >> ch;
        Switch(ch)
{
     case  ‘A’  :  cout << ” GRADE-A”;
     case ‘B’  :  cout  <<  “GRADE-B”;
                          break;
      case ‘C’  :  cout <<” GRADE-C”;
      default  :  cout << “GRADE-D”;
[PART-2]
cin >> ch;
        Switch(ch)
{
     case ‘F’  :  cout  <<  “GRADE-F”;
                      break;
      default  :  cout << “GRADE-D”;
      case ‘C’  :  cout <<” GRADE-C”;
     case  ‘A’  :  cout << ” GRADE-A”;
                       break;
     case ‘B’  :  cout  <<  “GRADE-B”;
       [PART-3]
                       
    char  outer , inner ;
    for (outer = ‘F’ ; outer >= ‘A’ ; --outer)
     {
         for (inner =   ‘A’ ; inner <= outer ; inner++)
  { cout <<inner ; }
   cout << endl;
    }
Q16. What will be the output of the following program ?
               #include<iostream.h>
               Void main()
              {
                         long number =5678901, result = 0;
do
{
   result *=10;
  int digit = number % 10;
  result +=digit;
number /=10;
} while (number);
Cout << “output = “<<result<<endl;
}
Q17. What will be the output of the following program?
#include<iostream.h>
int &max(int &x , int &y)
{
    if (x>y)
      return  x;
else
      return y;
}
Void main ()
{  
  int A=10,B=13;
  max(A,B)=-1;
cout<<”A=”<<A<<”B=”<<B<<endl;
max(B,A)=7;
cout<<”A=”<<A++<<”B”<<B--<<endl;
max(A,B)=3;
cout<<”A=”<<A<<”B=”<<B<<endl;
}
Q18. What will be the output of the following program?
#include<iostream.h>
Void main()
{  
   int m=20;
{
  int m=10*  ::m;
  cout <<”m=”<<m<<” ::m=”<<::m<<endl;
}
Q19. What will be the output of the following program?
#include<iostream.h>
Void Execute(int  &x , int  y = 200)
{  int temp=x+y;
    x+=temp;
If(y !=200)
  cout << temp<<x<<y<<endl;
}
Void main()
{ int a=50,b=20;
  Execute(b);
Cout<<a<<b<<endl;
Execute(a,b);
Cout<<a<<b<<endl;
}
Q20. What will be the output of the following program?
int sum (int arr[],int size);
int main()
{
  int val [] = {1,3,5,7,9,11,13,15,17,19};
int s1=0, s2=0;
S1=sum(val,10);
S2=sum(val+4,6);
cout<<”s1=”<<s1<<”\n”;
cout<<”s2 =”<<s2<<”\n”;
return 0;
}
int sum(int arr[],int size)
{   for (int i=0,s=0;i<size;++i)
     S+=arr[i];
Return s;
}







                         
     









Popular posts from this blog

XII- CS-- SOLVED SQL queries (SQL PRACTICAL ASSIGNMENS)

SQL--HOME ASSIGNMENTS(XII Class)

Python-MySQL Connectivity