Cute FTP Pro

Chapters 4 to 6


This is an evaluation test. Choose the answers and click on the "Submit" button to view your score. The correct answers with explanations will be shown after you take the test.

1.Q) If an array is initialized as shown below:

            int ar[5]={1,2,3};
            What will be the value for ar[3]?

Answer.)

null
0
1
undefined/unpredictable

 

2. Q.)    int ar[5];
            What will be the value for ar[3]?
Answer.)

null
0
1
undefined/unpredictable

 

3. Q.) Will the following code work (if it will, what's the output)?:

            int ar[5]={1,2,3};
            for (int i=0;i<5;i++)
            {
                        cout<<i[ar];
            }

 

Answer.)

program won't compile
unpredictable output
12300
123

 

4. Q.) In the below structure how can we access x?

             struct st1 {struct{struct{int x;} st2;} st3;}y;

 

Answer.)

x.st2.st3.y
y.st3.st2.x
st2.st3.y.x
st3.st2.y.x

 

5. Q.) Can you predict what will happen?

#include <iostream.h>
int main( )
{
unsigned int j=2;
cout<<j--;
while(j>=0)
{
    cout<<j--;
}
return 0;
}

 

Answer.)

Unpredictable behaviour
Output will be: 210
Output will be: 21
Infinite looping

 

6. Q.) Can main( ) be recursive? Answer.)

Yes
No
Depends on compiler

7. Q.) What will happen? 

int main( )
{
            int array1[]={1,2,3};
            int array2[]={10,20,30};
            array2=array1;
            return 0;
}

Answer.)

Runtime error
Compile-time error
Linker error
No errors

 

8. Q.) What is the result of the code given below: 

static int x=2; 

int main( )
{
int sum=0;
do
{
    sum+=(1/x);
}while(0<x--);
return 0;
}

Answer.)

Runtime error
Compile error
Linker error
No errors

 

9. Q.) What would be the output for the following code: 

int main( )
{
            int i=5; int j=6; int k=7;
            int result;
            result = j>k ? 2 : i>j ? 3 : 4;
            cout<<result;
            return 0;
}

Answer.)

2
3
4
compile-time error

 

10. Q.) What does the code fragment yield:

             const int SIZE = 5;
            int array1[SIZE]={1,2,3,4,5};
            cout<<array1[2,3];

Answer.)

1
2
3
4
compile-time error

11. Q.) Will the following code compile? 

int main( )
{
            int rad;
            cout<<"\nEnter the radius:";
            cin>>rad;
            if(rad>0)
            {
                        double area=3.14*3.14*rad;
                        cout<<area;
            }
return 0;

Answer.)

Runtime error
Compile error
Linker error
No errors

 

If you didn't get the solutions pop-up window then click here for the solutions page.


Go back to the Contents Page


Copyright 2005 Sethu Subramanian All rights reserved. Sign my guestbook.