Misc QA

MiSC QA



Ques 1. what is token? 

A. each and every units in c program are called tokens .
B. only variables
C. only constants
D. only function names


Ques 2. what are different types of token?




Ques 3. count number of tokens in the below code statement?

scanf("%d", &x);
options:
A. 7
B. 3
C. 6
D. 5


Ques 4. what type of language is c?

options:
A. it is high level language
B. it is low level language
C. it is a high level language with support to low level programming
D. it is super high language



Ques 5. if character size is 1 byte predict the output?

#include <stdio.h>
#include <stdlib.h>
char printchar()
{
  putchar('D');
  return 'D';
}
int main()
{
    printf("%d", sizeof(printchar()));

    return 0;
}

options:
A. 1
B. D 1
C. 1 D
D. compiler error


Ques 6. what is the output for the below code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int arr[][4] = {1,2,3,4,5,6,7,8} ;
int (*p)[4] = arr;

printf("%d, %d ", *((*p)+1), *((*p)+2));
++p;
printf("%d, %d ", (*p)[1], (*p)[2] );

    return 0;
}

options:
A. 2,3, 6,7
B. 1,2,3,4
C. 5,6,7,8
D. 1,2,5,6 


Ques 7. what is the answer for the for loop line in the below code?
#include <stdio.h>
#include <stdlib.h>

main()
{
 int index;
for(index=0, index<5, index++);
}

options:
A. lexical error
B. only syntax error
C. No compiler error
D. both lexical and syntax error


Ques 8. In C program when the macro defined is resolved?

options:
A. preprocessing time
B. compiling time
C. during linking
D. run time


Ques 9. In C program two files f1 and f2 are present, a funtion present in f2 is called in file f1.
when this is resolved?

options:
A. preprocessing time
B. compiling time
C. during linking
D. run time



Ques 10. In C program a variables declared defined, when this is resolved?

options:
A. preprocessing time
B. compiling time
C. during linking
D. run time


Ques 11. for the below code what is the right way of accessing the data?

int x,y,z;
int *mdn[4], xrg[2][3];

options:
A. mdn[1] = &x, xrg[1]=34
B. mdn[1] = &x, xrg[1][0]=34
C. mdn[4] = &x, xrg[3]=34
D. mdn[1] = &x, xrg[4]=34


Ques 12. what is the option correct for c language?

options:
A. it case insensitive language
B. a regular language
C. it case sensitive language
D. low level language


Ques 13. how the c language processing happen?

options:
A. preprocessing, compilation, linking
B. compilation, preprocessing, linking
C. linking, compilation, preprocessing
D. linking , preprocessing, compilation


Ques 14. what is the command for getting preprocessed file in linux?

options:
A. gcc -k filename.c
B. gcc -E filename.c
C. gcc -l filename.c
D. gcc -p filename.c


Ques 15. what is the command for getting object code file in linux?

options:
A. gcc -S filename.c
B. gcc -E filename.c
C. gcc -o filename.c
D. gcc -c filename.c


Ques 16. what is the command for getting assembly code file in linux?

options:
A. gcc -S filename.c
B. gcc -E filename.c
C. gcc -o filename.c
D. gcc -c filename.c


Ques 17. what is the command for getting outputfile after linking files in linux?

options:
A. gcc -S filename.c
B. gcc -E filename.c
C. gcc -o filename.c
D. gcc -c filename.c


Ques 18. what is the output for the following program?

#include <stdio.h>
#include <stdlib.h>

int disp(int m, int n)
{
    int p=m+n;
    printf("\n m = %d", m);
    return p;
}
int main()
{
    int p=3,q=4, k;
   int (*f)(int, int);
    f=disp;
    k=f(p,q);
printf("\n k= %d",k);
    return 0;
}

options:
A. 3 7
B. compiler error
C. runtime error 
D. 7 7 


Ques 19. what is the output for the following program?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int p=0x55 ;
    p = 0xb>>1<<2;
    printf("\n p= %x",p);
    return 0;

}

options:
A. a8
B. compiler error
C. runtime error 
D. 14 


Ques 20. what is the output for the following program?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int p=0x55 ;

     p = (p & 0xff) & (~(1<<2)) ;

     printf("\n p= %x",p);

    return 0;
}


options:
A. 51
B. 54
C. 58
D. 55 



Answers

1. A 2. the different types of tokens are Keywords (ex. int float while, case), Identifiers(ex. main, sum, total), Contants(ex, 44,67) strings (ex: "sum", "welcome", "ptinstitute.in" ) Special symbols (ex: (), {}) Operators (ex: +,-,/, *) 3. 7 4. C 5. 1 6. A 7. B 8. A 9. C 10. B 11. B 12. C 13. A 14. B 15. C 16. A 17. C 18. A 19. D 20. A