Declaration

1

Identify the type of the variables.
 typedef char* CHAR;
 CHAR p,q;

A. char*
B. char
C. CHAR
D. unknown

2

Identify the incorrect statements.
 int var = 10;
 int *ptr = &(var + 1); //statement 1
 int *ptr2 = &var; //statement 2
 &var = 40; //statement 3

A. Statement 1 and 2 are wrong
B. Statement 2 and 3 are wrong
C. Statement 1 and 3 are wrong
D. All the three are wrong

3

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        int a = 10;
6.        
        if (a < 10) {
7.        
            for (i = 0; i < 10; i++)
8.            
               cout << i;
9.               
        }
10.        
        else {
11.
            cout << i;
12.            
        }
13.        
        return 0;
14.        
    }
A. 0123456789
B. 123456789
C. 0
D. error

4

What is the output of this program?

1.
    #include 
2. 
    using namespace std;
3.    
    void addprint()
4.    
    {
5.    
        static int s = 1;
6.        
        s++;
7.        
        cout << s;
8.        
    }
9.    
    int main()
10.    
    {
11.    
        addprint();
12.        
        addprint();
13.        
        addprint();
14.        
        return 0;
15.        
    }
A. 234
B. 111
C. 123
D. 235

5

Can two functions declare variables(non static) with the same name.

A. No
B. Yes
C. Yes, but not a very efficient way to write programs.
D. No, it gives a runtime error.