[amp_mcq option1=”char type of variable” option2=”string type of variable” option3=”conversion specification %s” option4=”All of the above” correct=”option4″]
The correct answer is: D. All of the above
A string is a sequence of characters. In C, a string can be assigned to a variable of type char or string. The conversion specification %s is used to read a string from the standard input.
Here are some examples of how to assign a string to a variable:
char str[] = "Hello, world!";
string str2 = "Hello, world!";
Here is an example of how to read a string from the standard input:
char str[100];
scanf("%s", str);
The %s conversion specification tells the compiler to read a string from the standard input and store it in the variable str. The 100 in the char str[100] declaration tells the compiler to allocate enough space for 100 characters.
I hope this helps!