Quiz 7 (Improvement) And Assignment 4 - Bee-2a *

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Aamirakbar2
A
Aamirakbar2
Community Contributor
Quizzes Created: 1 | Total Attempts: 57
| Attempts: 57 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. Strings in C are char array..

Explanation

In C programming, strings are represented as character arrays. A string is a sequence of characters stored in consecutive memory locations, terminated by a null character '\0'. Therefore, the given statement "Strings in C are char array" is true.

Submit
Please wait...
About This Quiz
Quiz 7 (Improvement) And Assignment 4 - Bee-2a * - Quiz

This quiz assesses knowledge in C programming, focusing on string handling, memory errors, and basic syntax.

Personalize your quiz and earn a certificate with your name on it!
2. The ___ used in printf( ) is a format specification for printing out a string

Explanation

The format specification %s is used in the printf() function to print out a string. This means that when using %s in printf(), the corresponding argument should be a string that will be printed out.

Submit
3.  char *str[1][2] = {"June", "6"}; printf("Month name is %s, which is %dth month of the year", ___ , ___ );What should be in the blanks to give the following outputMonth name is June, which is 6th month of the year

Explanation

The correct answer is "str[0][0], atoi(str[0][1])".

In the given code, the array "str" is a 2D array of character pointers. It is initialized with two strings: "June" and "6".

In the printf statement, we need to print the first element of the first row of the array, which is "June", and the second element of the first row of the array, which is "6".

So, "str[0][0]" gives us "June", and "str[0][1]" gives us "6". The "atoi" function is used to convert the string "6" to an integer.

Therefore, the correct answer is "str[0][0], atoi(str[0][1])".

Submit
4. Gets() function is used to _____

Explanation

The gets() function is used to get a string from the user. It reads characters from the standard input until a newline character is encountered and stores them in the string. This function is specifically designed for reading strings and should not be used for any other type of input.

Submit
5. Char str[20] = "hello bee2a";printf("%s", str);Output = hello bee2a

Explanation

The given code will output "hello bee2a" because it uses the printf function to print the string stored in the variable "str". Therefore, the correct answer is False.

Submit
6.  char *str[] = {"Hello Bee2A"}; *str = "Bye Bee2A"; puts(*str);Output = __________

Explanation

The code declares an array of character pointers named "str" and initializes it with the string "Hello Bee2A". Then, it assigns the address of the string "Bye Bee2A" to the first element of the array. Finally, the code prints the value at the address pointed to by the first element of the array using the puts() function. Therefore, the output will be "Bye Bee2A".

Submit
7.  char *str[] = {"2014"}; int year = atoi(str[0]); printf("___", year);What should be the format specifier?

Explanation

The correct format specifier in this case should be %d. This is because the variable "year" is an integer, and the printf function is used to print the value of an integer variable. The %d format specifier is used specifically for integers.

Submit
8. We can store both int and char data in a char two-dimensional array?

Explanation

A char two-dimensional array can only store characters, not integers. Integers would need to be converted to characters before being stored in the array. Therefore, it is not possible to store both int and char data in a char two-dimensional array.

Submit
9. Char str[10] = "A quick brown fox jumped over a lazy dog";puts(str);what will print?

Explanation

The given code will result in an error. This is because the size of the character array "str" is 10, but the assigned string "A quick brown fox jumped over a lazy dog" has a length of 42 characters (including the null terminator). Thus, the assigned string is too long to fit into the character array, causing a buffer overflow and resulting in an error.

Submit
10. Char str1[10] "Hello!";int count1 = 0;    while(str1[count1] != '\0')        count1++;while loops will iterate until ______

Explanation

The while loop will iterate until the condition `str1[count1] != '\0'` is true. In this case, the loop will continue until the null character (`'\0'`) is encountered in the string `str1`. Since the string `str1` has a size of 10 and is initialized with the characters "Hello!", the loop will iterate 10 times before reaching the null character at the end of the string. Therefore, 10 is the correct answer.

Submit
View My Results

Quiz Review Timeline (Updated): May 29, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • May 29, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 12, 2014
    Quiz Created by
    Aamirakbar2
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Strings in C are char array..
The ___ used in printf( ) is a format specification for printing out...
 char *str[1][2] = {"June",...
Gets() function is used to _____
Char str[20] = "hello bee2a";printf("%s",...
 char *str[] = {"Hello Bee2A"}; *str = "Bye...
 char *str[] = {"2014"}; int year =...
We can store both int and char data in a char two-dimensional array?
Char str[10] = "A quick brown fox jumped over a lazy...
Char str1[10] "Hello!";int count1 = 0;  ...
Alert!

Advertisement