//adsense code

UNIT-4 : POINTERS AND STRINGS


1.        Address stored in pointer variable is of                  type

A. Integer                   B.character                 C. Float                                    D.Double

2.        Pointer variable is declared using preceding with              sign


A. %                            B.&                             C.^                   D.*

3.        * is called as                       

A. Value at pointer  B.Address operator     C. Scope resolution operator D.None

4.        Multiple indirection operator is                 

A.-->                           B.&                             C.*                  D.**

5.        Prior to using a pointer

A. it should be declared                                  B. it should be initialized

C. it should be declared and initialized      D.None

6.        int *p1,*p2;    find out valid statement

A. p1-p2                     B.p1*p2                                          C.p1+p2                                          D.p1/p2 7. int k[3]={1,2,3};int *p;

one of the following statement is equal to p=k is

A. p=&k[0]                B. p=&k[1]                 C.p=&k[2]                  D. None

8.        A pointer to pointer points to the address of a

A. Structure                B.Union                      C.Array           D.Pointer

9.        Size of the pointer depends upon                  

A. Processor              B. RAM                      C. Hard disk                D.All

10.   What is the size of the double pointer? Ex: double *ptr; in 16 bit processor

A. 4 bytes                    B. 2 bytes                   C. 10 bytes                  D. 8 bytes

11.   Which is the correct way to declare a pointer?

A. int *ptr;                  B.int  * ptr;                C. int*  ptr;                 D. All

12.   Generally , functions are classified into

A. 1 type                     B. 2 types                    C. 3 types                    D. 4 types

13.   How to combine the following two statements into one? char *p;

p=(char*)malloc(100);

(a) char p=*malloc(100);                  (b) char *p=(char)malloc(100);

(c) char *p=(char*)malloc(100);   (d) char *p=(char*)(malloc*)(100);

14.   A pointer is

(a)  A keyword used to create variables

(b)  A variable that stores address of an instruction

(c)  A variable that stores address of other variable

(d)  All of the above

15.   The operator used to get value at address stored in a pointer variable is

(a)*                 (b) &              (c)  &&                       (d)  ||

16.   What would be the equivalent pointer expression for referring the array element a[i][j][k][l] (a) ((((a+i)+j)+k)+l)     (b)  *(*(*(*(a+i)+j)+k)+l)

(c) (((a+i)+j)+k+l)                 (d) ((a+i)+j+k+l)

17.   If the size of integer is 4 bytes, what will be the output of the program?




 

 

 


int main()

{

int arr[]={12,13,14,15,16};

printf(%d, %d, %d\n‖,sizeof(arr),sizeof(*arr),sizeof(arr[0])); return 0;

}

a)   10, 2, 4                  (b)  20, 4, 4                 (c) 16, 2, 2                   (d) 20, 2, 2

18.   Which of the following statements correct about k used in the below statement? char ****k;

(a)  k is a pointer to a pointer to a pointer to a char

(b) k is a pointer to a pointer to a pointer to a pointer to a char

(c)  k is a pointer to a char pointer

(d)  k is a pointer to a pointer to a char

19.      What will be the output? main()

{

char *p;

printf(%d   %d,sizeof(*p),sizeof(p));

}

(a) 1    1                      (b)  1   2                      (c) 2    1                      (d) 2    2

20.   What will be the output? main()

{

printf(%d   %d,sizeof(int *),sizeof(int **));

}

(b) 4    4                      (b)  0    2                    (c) 2    2                      (d) 2    4

21.                         Which one of the following is a string constant

(a) ‗3‘ (b) “hello”     (c) 30               (d) None

22. Which of the following is used to display a string on the screen?

(a) %s             (b) %c             (c) %d             (d) %f

23. Which of the following is used to determine the length of a string?

(a) strlen        (b) strcmp       (c) strcpy         (d) strcat

24. Which of the following is the correct syntax for copying a string S1 into S2?

(a) strcpy(S2,S1);      (b) strcpy(S1,S2);       (c) strcmp(S1.S2);      (d) strcmp(S2,S1);

25. The function strcat(S2,S1) appends          to         _

(a) S1,S2         (b) S2,S1         (c) S2,S2         (d) S1,S1

26.   Which of the following is used to read a string

(a) getchar()    (b) gets()         (c) getstr()       (d) getch()

27.   Which function is used to search for a substring in a string?

(a) strchr         (b) strstr         (c) strspn         (d) strcpy

28.   How many arguments that the strcmp() function can take?



(a) 2                (b) 3                (c) 4                 (d) 0


 

 

 

29.  
What will be the result of the following character arithmetic expression?

X=‘A‘-2

(a) 63              (b) 64              (c) 65               (d) 66

30.   Which of the following header file is required for performing string operations

(a) stdio.h        (b) conio.h      (c) string.h     (d) ctype.h

31.  Which function is used to count and return the number of characters in a given string A) strcmp()         B) strlen()   C) strrev()              D) strcat()

32.   If the two strings are identical, then strcmp() returns                       (a) -1              (b) 1              (c) 0    (d) yes

33.   Which of the following function is more appropriate for reading in a multi-word string?

(a) printf()       (b) scanf()       (c) gets()         (d) puts()

34.   Which of the following not belongs to String functions?

A. strcmp()     B. strcat()                    C.strlen()        D. isdigit()

35.   Which function is used to reverse the string?

(a) reverse()    (b) strrev()     (c) rev()           (d) None

36.   What will be the output of the program? void main()

{

char str1[20] = "Hello", str2[20] = " World"; printf("%sn", strcpy(str2, strcat(str1, str2)));

}

(a) HelloWorld          (b) World        (c) WorldHello           (d) Hello

37.   What will be the output of the program? void main()

{

char str[ ] = "online\0exam‖; printf(%s‖,str);

}

(a) online\0exam         (b) online       (c) onlineexam            (d) exam

38.   String concatenation means

(a) Combining two strings                           (b) Extracting a substring out of a string

(c) Comparing two strings                              (d) partitioning the string into two strings

39.   Which function locates the first occurrence of the character in a given string

(a) strstr()                  (b) strchr()                 (c) strrchr()                 (d) strrstr()

40.   What is the output of the following code main()

{          char str1[ ]=‖mahendra singh‖,str2[ ]=‖dhoni captain‖; strncat(str1,str2,5);

printf(\n %s,str1);

}


(a) mahendra singhdhoni     (b) mahendra singhdhoni captain

(c) mahendra singh                 (d) None

Related Posts

Subscribe Our Newsletter

0 Comments to "UNIT-4 : POINTERS AND STRINGS"

Post a Comment

Share your view here!!