C Fundamentals - Study Mode
[#186] What will be the output of the following C code? #include <stdio.h>
int main()
{
if (~0 == 1)
printf("yes
")
else
printf("no
")
}
Correct Answer
(B) no
[#187] Which data type is used to store a sequence of characters in C?
Correct Answer
(A) char
Explanation
Solution: The data type used to store a sequence of characters in C is Option A: char . In C, you can use an array of characters (often referred to as a "string") or simply a single character variable to store individual characters or sequences of characters. So, the correct answer is: Option A: char In C, you can declare a character array (string) like this: char myString[] = "Hello, World!"
In this example, 'myString' is an array of characters, and it can store a sequence of characters, including letters, digits, symbols, and spaces.
[#188] In C, which operator is used for pointer-to-pointer relationships?
Correct Answer
(A) *
Explanation
Solution: In C, the operator used for pointer-to-pointer relationships is Option A: * . The asterisk () operator is used for both declaring and dereferencing pointer variables. When you have a pointer-to-pointer (a pointer that points to another pointer), you use multiple asterisks to access the value pointed to by the second pointer. So, the correct answer is: Option A: * Here's an example of a pointer-to-pointer relationship in C: int num = 42
int *ptr1 = # // Pointer to an integer
int **ptr2 = &ptr1 // Pointer to a pointer to an integer
// Access the value using the pointer-to-pointer
int value = **ptr2
// value is now 42 In this example, ptr2 is a pointer-to-pointer, and **ptr2 is used to access the value stored in num.
[#189] Comment on the following statement. n = 1
printf("%d, %dn", 3*n, n++)
Correct Answer
(D) Output is compiler dependent
[#190] Which of the following format identifier can never be used for the variable var? #include <stdio.h>
int main()
{
char *var = "The quick brown fox jumps over the lazy dog"
}
Correct Answer
(A) %f