help answer the following questions in C programming 1char s
help answer the following questions in C programming.
1.char str[10] has a size of
a 9 bytes
b 10 bytes
c 11 bytes
2. if str is used as a string, char str[10] can contain_meaningful characters.
a 9
b 10
c 11
3. the end of a string in c always contains
a the character ´0´
b the ASCII value 0
c the string ´0´
4.the null termination at the end of a C string is used to
a keep you from overflowing the array
b store the length of the string
c determine where the end of the string is
d shorten the length of the array
5. if you try 60 character long string in 10 character long array:
a you will get a compiler error
b you will not get a compiler error but you will have a bug in your program
c you will have a compiler warning and you might have a bug in your program
d the array will expand to handle it
6. assigning a value to a string is done like this:
a str = blah;
b str = ´blah´;
c strcpy(str, \"blah\");
d strcpy(str, \'blah\' );
7. string equality comparison is done using:
a ==
b =
c strcpy()
d strcpy()
8. A limitation of using atoi() is
a it doesnt work on strings
b it only handles positive integers
c you cant tell the difference between invalid input and the user entering 0
d it requires the use of a format string
9. one important problem with using fgets() is
a you cant control the amount of input entered by the user
b it puts a \'\ \' (that you have to take into account) at the end of most input
c you cant use it for getting input from the keyboard.
10. fgets() is better than gets() because:
a it allows you to specify a format string for input
b it allows you to get numbers as input
c it helps with avoiding overflowing the array
Solution
1.char str[10] has a size of 10 bytes.
2.If str is used as a string, char str[10] can contain 9 meaningful characters.
3.The end of a string in c always contains the character ´0´.
4.The null termination at the end of a C string is used to determine where the end of the string is.
5.If you try 60 character long string in 10 character long array: you will have a compiler warning and you might have a bug in your program.
7.string equality comparison is done using: ==.
10.fgets() is better than gets() because: it helps with avoiding overflowing the array.
![help answer the following questions in C programming. 1.char str[10] has a size of a 9 bytes b 10 bytes c 11 bytes 2. if str is used as a string, char str[10] c help answer the following questions in C programming. 1.char str[10] has a size of a 9 bytes b 10 bytes c 11 bytes 2. if str is used as a string, char str[10] c](/WebImages/26/help-answer-the-following-questions-in-c-programming-1char-s-1067587-1761558697-0.webp)
![help answer the following questions in C programming. 1.char str[10] has a size of a 9 bytes b 10 bytes c 11 bytes 2. if str is used as a string, char str[10] c help answer the following questions in C programming. 1.char str[10] has a size of a 9 bytes b 10 bytes c 11 bytes 2. if str is used as a string, char str[10] c](/WebImages/26/help-answer-the-following-questions-in-c-programming-1char-s-1067587-1761558697-1.webp)