ExamVeda
Login
Home
31
Find the output of the following program:
void main()
{
   struct xx
   {
      int x=3;
      char name[]="hello";
   };
   struct xx *s;
   printf("%d", s->x);
   printf("%s", s->name);
}
Discuss
Answer & Solution
Answer: Option D
Solution:

You cannot initialize members in structure declaration.

32
Consider the following code.
struct account{
   int acno;
}svar, *pv = &svar;

then the acno can be accessed by
Discuss
Answer & Solution
Answer: Option D
Solution:

As all the ways are legal and valid.

33
Consider the following declarations:
union id
{
   char color;
   int size;
};
struct{
   char country;
   int date;
   union id id;
}flag;

To assign a color to a flag, the correct statement would be
Discuss
Answer & Solution
Answer: Option A
Solution:

2

34
For the following structure declaration, find the correct statement.
struct person{
   char name[20];
   int  age;
   struct person lady;
};
Discuss
Answer & Solution
Answer: Option D
Solution:

As we cannot create a variable of itself as a member of the structure, but a reference can be created to create a self referential structure.

35
The restriction with union is
Discuss
Answer & Solution
Answer: Option A
Solution:

As all the members shares the same memory.

36
How many union members can be initialized?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
37
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    typedef struct p *q;
    struct p
    {
        int x;
        char y;
        q ptr;
    };
    struct p p = {1, 2, &p};
    printf("%d\n", p.ptr->x);
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
38
Can the following C code be compiled successfully?
#include <stdio.h>
struct p
{
    int k;
    char c;
    float f;
};
int main()
{
    struct p x = {.c = 97, .f = 3, .k = 1};
    printf("%f\n", x.f);
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
39
What will be the output of the following C code?
#include <stdio.h>
int *(*(x()))[2];
typedef int **(*ptrfoo)())[2];
int main()
{
    ptrfoo ptr1;
    ptr1 = x;
    ptr1();
    return 0;
}
int *(*(x()))[2]
{
    int (*ary)[2] = malloc(sizeof * ary);
    return &ary;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
40
Which of the following share a similarity in syntax?
1. Union, 2. Structure, 3. Arrays and 4. Pointers
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board