Structure And Union - Study Mode

[#116] What will be the output of the following C code according to C99 standard? #include <stdio.h>
struct p
{
int k
char c
float f
}
int main()
{
struct p x = {.c = 97, .k = 1, 3}
printf("%f
", x.f)
}
Correct Answer

(B) 0.000000

[#117] What will be the output of the following C code? #include <stdio.h>
struct student
{
int no = 5
char name[20]
}
void main()
{
struct student s
s.no = 8
printf("hello")
}
Correct Answer

(B) Compile time error

[#118] What will be the output of the following C code? #include <stdio.h>
struct student
{
char *name
}
struct student s
struct student fun(void)
{
s.name = "newton"
printf("%s
", s.name)
s.name = "alan"
return s
}
void main()
{
struct student m = fun()
printf("%s
", m.name)
m.name = "turing"
printf("%s
", s.name)
}
Correct Answer

(A) newton alan alan

[#119] What will be the output of the following C code? #include <stdio.h>
typedef int integer
int main()
{
int i = 10, *ptr
float f = 20
integer j = i
ptr = &j
printf("%d
", *ptr)
return 0
}
Correct Answer

(D) 10

[#120] What will be the output of the following C code? #include <stdio.h>
struct point
{
int x
int y
}
void foo(struct point*)
int main()
{
struct point p1[] = {1, 2, 3, 4}
foo(p1)
}
void foo(struct point p[])
{
printf("%d
", p[1].x)
}
Correct Answer

(B) 3