C Objective

1. What is the output of the program given below     
     #include<stdio.h> 
     main() 
     { 
             char i=0; 
             for(;i>=0;i++) ; 
             printf("%d\n",i); 
     } 

Output: -128

2. Which one MUST be correct in the following statements ? 
     a) All Identifiers are keywords 
     b) All Keywords are Identifiers 
     c) Keywords are not Identifiers 
     d) Some keywords are Identifiers 

Output: c


3.How much memory is allocated by the following definition ? 
    int (*x)[10]; 

Output: 4 bytes

4.What is the memory allocated by the following definition ?
   
 int (*x)(); 

Output: 4 bytes

5.What is the Output of the Program ?
   
main() 
   { 
         int i = 1 ; 
         printf(i ?"one" : "zero") ; 
   } 
a) one 
b) zero 
c) error 
d) both and b 

Output: a


6.What is the Output of the Program ? 
   main() 
   {  
       int i = 1 ; 
       printf("%d",i ? 1 : 0) ; 
   } 
a) 1 
b) 0 
c) error 
d) none of the above 

Output: a


7.What is the output for the program given below 
    typedef enum grade{GOOD,BAD,WORST,BAD}; 
    main() 
    { 
           BAD g1; 
           g1=1; 
           printf("%d",g1); 
    } 

Output:
      error (cant define twice BAD)

8.Give the output for the following program.
    
    #define STYLE1 char 
    main() 
    { 
          typedef char STYLE2; STYLE1 x; 
          STYLE2 y; 
          clrscr(); 
          x=255; 
          y=255; 
          printf("%d %d\n",x,y); 
     } 

Output: -1-1

9.Which of 'Arrays' or 'pointers' are faster ?
    
    a) Arrays 
    b) pointers 
    c) Both take same time 
    d) Can't say 

Output: a


10.In the following program 
     #include<stdio.h> 
     main() 
     { 
          char *pDestn,*pSource="I Love India"; 
          pDestn=malloc(strlen(pSource)); 
          strcpy(pDestn,pSource); 
          printf("%s",pDestn); free(pDestn); 
     } 
    a) Free() fails 
    b) Strcpy() fails 
    c) prints I love India <Garbage> 
    d) error

Output: c

No comments:

Post a Comment