0% found this document useful (0 votes)
8 views

Assignment 20 Stringfunctions Ans

This document contains 20 multiple choice questions about C programming concepts related to functions, strings, and arrays. The questions cover topics like gets(), strlen(), strcpy(), strcat(), and 2D arrays.

Uploaded by

Yash rai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment 20 Stringfunctions Ans

This document contains 20 multiple choice questions about C programming concepts related to functions, strings, and arrays. The questions cover topics like gets(), strlen(), strcpy(), strcat(), and 2D arrays.

Uploaded by

Yash rai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Assignment of objective questions

1. Does gets() function scans enter key press by the user during input

a. Yes
b. No
c. Only in Turbo Compiler
d. Only in GCC Compiler

Answer - a. Yes

2. String functions are available in the header file named...

a. conio.h
b. stdio.h
c. stdlib.h
d. string.h

Answer - d. string.h

3. strlen() function returns the...

a. length of the string


b. the last character of the string
c. the first character of the string
d. None of the above

Answer - a. length of the string


4. The data passed as an argument to the function known as...

a. Function Argument
b. Function Variable
c. Passed Value
d. Passed Data

Answer - a. Function Argument

5. Full Form of IVT is...

a. Interrupt Vector Table


b. International Vector Table
c. Important Vector Table
d. Internal Vector Table

Answer - a. Interrupt Vector Table

6. Predict the output


char city[10];
city = {"Bhopal"};

a. "Bhopal" will be stored in array city


b. Runtime Error
c. Compilation Error
d. Unpredictable output

Answer - c. Compilation Error


7. Predict the output
char city[10] = {"Bhopal"};

a. "Bhopal" will be stored in array city


b. Runtime Error
c. Compilation Error
d. Unpredictable output

Answer - a. "Bhopal" will be stored in array city

8. Predict the output


char city[10] = "Bhopal";

a. "Bhopal" will be stored in array city


b. Runtime Error
c. Compilation Error
d. Unpredictable output

Answer - a. "Bhopal" will be stored in array city

9. Predict the output


char city[10] = {'B', 'h', 'o', 'p', 'a', 'l'};

a. "Bhopal" will be stored in array city


b. Runtime Error
c. Compilation Error
d. Unpredictable output

Answer - a. "Bhopal" will be stored in array city


10. Predict the output
char city[10] = {'B', 'h', 'o', 'p', 'a', 'l', '\0'};

a. "Bhopal" will be stored in array city


b. Runtime Error
c. Compilation Error
d. Unpredictable output

Answer - a. "Bhopal" will be stored in array city

11. Predict the output


char city[10];
strcpy(city, "Bhopal");

a. "Bhopal" will be stored in array city


b. Runtime Error
c. Compilation Error
d. Unpredictable output

Answer - a. "Bhopal" will be stored in array city

12. Predict the output


char arr[10] = {"bhopal"}, brr[10];
brr = arr;

a. String "Bhopal" will be stored in both the arrays


b. Address of arr will be stored in brr
c. Both array size will become of the length of "Bhopal"
d. Compilation Error.

Answer - d. Compilation Error.


13. strcpy() takes two arguments which represent...

a. source array and destination array


b. destination array and source array
c. target array and given array
d. first array and second array

Answer - b. destination array and source array

14. Predict the output


char city[10];
city[0] = 'B';
city[1] = 'h';
city[2] = 'o';
city[3] = 'p';
city[4] = 'a';
city[5] = 'l';

a. "Bhopal" will be stored in array city


b. Runtime Error
c. Compilation Error
d. Unpredictable output

Answer - d. Unpredictable output

15. Predict the output


char arr[] = "Hi", brr = "User";
strcat(arr, brr);
printf("arr:%s\n", arr);

a. "HiUser"
b. "Hi User"
c. " Hi User "
d. "HiUser "

Answer - a. "HiUser"
16. Return type of function strcmp() is...

a. int
b. char
c. float
d. double

Answer - a. int

17. Function strcmp() returns negative value when...

a. String of the first array is smaller than the second array


b. The string of the second array is smaller than the first array
c. The first array contains a special character
d. The second array contains special character

Answer - a. String of the first array is smaller than the second array

18. Predict the output


char str[5][10];

a. 5 strings of string length 10 can be stored.


b. 10 strings of string length 5 can be stored.
c. 15 strings of string length 10 can be stored.
d. 15 strings of string length 5 can be stored.

Answer - a. 5 strings of string length 10 can be stored.


19. Predict the output
char str[5][10];
for(i = 0; i < 5; i++)
{
printf("Enter Name:");
scanf("%s", str[i]);
}

a. Accepts 5 Name from the user


b. Unpredictable output
c. Runtime Error
d. Compilation Error

Answer - a. Accepts 5 Name from the user

20. Predict the output


char name[2][10] = {'b', 'h', 'o', 'p', 'a', 'l', '\0', 'i', 'n
, 'd', 'o', 'r', 'e', '\0'};
printf("name[0]:%s, name[1]:%s\n", name[0], name[1]);

a. name[0]:bhopal, name[1]:indore
b. name[0]:bhopal, name[1]:ore
c. name[0]:bhopal, name[1]:dore
d. name[0]:bhopal, name[1]:ndore

Answer - b. name[0]:bhopal, name[1]:ore

You might also like