Structure And Union - Study Mode
[#106] What will be the output of the following C code? #include <stdio.h>
void main()
{
char *a[3] = {"hello", "this"}
printf("%s", a[1])
}
Correct Answer
(C) this
[#107] What will be the output of the following C code? #include <stdio.h>
struct student
{
char *name
}
struct student fun(void)
{
struct student s
s.name = "alan"
return s
}
void main()
{
struct student m = fun()
printf("%s", m.name)
}
Correct Answer
(B) alan
[#108] What is the correct syntax to declare a function foo() which receives an array of structure in function?
Correct Answer
(A) void foo(struct *var)
[#109] What will be the output of the following C code? #include <stdio.h>
struct student
{
char *c
}
void main()
{
struct student *s
s->c = "hello"
printf("%s", s->c)
}
Correct Answer
(B) Segmentation fault
[#110] For what minimum value of x in a 32-bit Linux OS would make the size of s equal to 8 bytes? struct temp
{
int a : 13
int b : 8
int c : x
}s
Correct Answer
(C) 12