C Programming 11

COEP
Lets Crack Online Exam

IT Interview Exam Questions: C Programming 11 (IT Interview Exam Question, IT Campus Placement)

Subject: C Programming 11

Part 11: List for questions and answers of C Language

 

Q1. Which of the following function is used to find the first occurrence of a given string in another string?

a) strchr()

b) strrchr()

c) strstr()

d) strnset()

 

Q2. The library function used to find the last occurrence of a character in a string is

a) laststr()

b) strstr()

c) strnstr()

d) strrchr()

 

Q3. Which of the following function sets first n characters of a string to a given character?

a) strinit()

b) strnset()

c) strset()

d) strcset()

 

Q4. If the two strings are identical, then strcmp() function returns

a) -1

b) 1

c) 0

d) Yes

 

Q5. How will you print \n on the screen?

a) printf(“\n”);

b) echo “\\n”;

c) printf(‘\n’);

d) printf(“\\n”);

 

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

a) printf();

b) scanf();

c) gets();

d) puts(); 

 

Q7. The return-type used in String operations are

a) void only

b) void and (char *) only

c) void and int only

d) void, int and (char *) only

 

Q8. String operation such as strcat(s, t), strcmp(s, t), strcpy(s, t) and strlen(s) heavily rely upon

a) Presence of NULL character

b) Presence of new-line character

c) Presence of any escape sequence

d) None of the mentioned

 

Q9. Which pre-defined function returns a pointer to the last occurence of a character in a string?

a) strchr(s, c);

b) strrchr(s, c);

c) strlchr(s, c);

d) strfchr(s, c);

 

Q10. Which of the following function compares 2 strings with case-insensitively?

a) strcmp(s, t)

b) strcmpcase(s, t)

c) strcasecmp(s, t)

d) strchr(s, t)

 

Q11. What will be the value of var for the following? var = strcmp(“Hello”, “World”);

a) -1

b) 0

c) 1

d) strcmp has void return-type

 

Q12. What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        char str[10] = “hello”;

        char *p = strrchr(str, ‘l’);

         printf(“%c\n”, *(++p));

    }

a) l

b) o

c) e

d) Compilation error 

 

Q13. The function sprintf() works like printf(), but operates on ……….

a) Data file

b) stderr

c) string

d) no such function in ‘C’

 

Q14. String concatenation means

a) Combining two strings

b) Extracting a substring out of a string

c) Partitioning the string into two strings

d) Merging two strings

 

Q15. What is the return value of the following statement if it is placed in C program? strcmp(“ABC”, “ABC”);

a) -1

b) 1

c) 0

d) Compilation Error

 

Q16. int a[5] = {1,2,3} What is the value of a[4]?

a) 1

b) 2

c) 0

d) Garbage Value

 

Q17. What will be output when you will execute following c code?

#include<stdio.h>

void main(){

    char arr[7]=”Network”;

    printf(“%s”,arr);

}

Choose all that apply:

a) Network

b) N

c) Garbage value

d) Compilation error

 

Q18. What will be output when you will execute following c code?

#include<stdio.h>

void main(){

    char arr[11]=”The African Queen”;

    printf(“%s”,arr);

}

Choose all that apply:

a) The African Queen

b) The

c) The African

d) Compilation error 

 

Q19. What will be output when you will execute following c code?

#include<stdio.h>

#define var 3

void main(){

    char *cricket[var+~0]={“clarke”,”kallis”};

    char *ptr=cricket[1+~0];

    printf(“%c”,*++ptr);

}

Choose all that apply:

a) a

b) r

c) l

d) Compilation error

 

Q20. What will be the output of the program ?int main(){ printf(“Code”, “Quiz\n”);return 0;}

a) Error

b) Code Quiz

c) Code

d) Quiz 

 

Part 11: List for questions and answers of C Language

 

Q1. Answer: c

 

Q2. Answer: d

 

Q3. Answer: b

 

Q4. Answer: c

 

Q5. Answer: d

 

Q6. Answer: c

 

Q7. Answer: d

 

Q8. Answer: a

 

Q9. Answer: b

 

Q10. Answer: c

 

Q11. Answer: a

 

Q12. Answer: b

 

Q13. Answer: c

 

Q14. Answer: a

 

Q15. Answer: c

 

Q16. Answer: c

 

Q17. Answer: c

 

Q18. Answer: d

 

Q19. Answer: c

 

Q20. Answer: c