adplus-dvertising
frame-decoration

Question

What is the output of this C code?
#include <stdio.h>
    struct point
    {
        int x;
        int y;
    } p[] = {1, 2, 3, 4, 5};
    void foo(struct point*);
    int main()
    {
        foo(p);
    }
    void foo(struct point p[])
    {
        printf("%d %d\n", p->x, p[2].y);
    }

a.

1 0

b.

Compile time error

c.

1 somegarbagevalue

d.

Undefined behaviour

Posted under C Programming

Answer: (a).1 0

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this C code?

Similar Questions

Discover Related MCQs

Q. Which of the following are incorrect syntax for pointer to structure?
(Assuming struct temp{int b;}*my_struct;)

Q. Which of the following is an incorrect syntax to pass by reference a member of a structure in a function?
(Assume: struct temp{int a;}s;)

Q. For the following function call which option is not possible?
func(&s.a); //where s is a variable of type struct and a is the member of the struct.

Q. Presence of loop in a linked list can be tested by the compiler by

Q. Which of the following is not possible?

Q. Which of the following techinique is faster for travelling in binary trees?

Q. Which function is responsible searching in the table?
(For #define IN 1, the name IN and replacement text 1 are stored in a “table”)

Q. Which algorithm is used for searching in the table?

Q. Which function is responsible for recording the name “s” and the replacement text “t” in a table?

Q. Which of the following is true?

Q. What happens when install(s, t) finds that the name being installed is already present in table?

Q. In what situation, install function returns NULL?

Q. For the following expression to work, which option should be selected.
string p = “HELLO”;

Q. Which of the given option is the correct method for initialization?
typedef char *string;

Q. Which of the following is FALSE about typedef?

Q. typedef int (*PFI)(char *, char *) creates

Q. typedef declaration

Q. Size of a union is determined by size of the

Q. Members of a union are accessed as________________

Q. Which of the following share a similarity in syntax?
1. Union, 2. Structure, 3. Arrays and 4. Pointers