ExamVeda
Login
Home
1
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;
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
2
What will be the output of the following C code?
#include <stdio.h>
struct p
{
    char *name;
    struct p *next;
};
struct p *ptrary[10];
int main()
{
    struct p p, q;
    p.name = "xyz";
    p.next = NULL;
    ptrary[0] = &p;
    strcpy(q.name, p.name);
    ptrary[1] = &q;
    printf("%s\n", ptrary[1]->name);
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
Solution:
In this code, the variable q is declared but not initialized. When you try to use strcpy function to copy the value of p.name to q.name, you are accessing memory that has not been allocated for q.name, which leads to undefined behavior. This undefined behavior could result in a segmentation fault or a code crash. Therefore, the correct answer is Option B: Segmentation fault/code crash.
3
Which of the following cannot be a structure member?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
4
Bit fields can only be declared as part of a structure.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
5
Which of the following reduces the size of a structure?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
6
What will be the output of the following C code?
#include <stdio.h>
struct student
{
    char *c;
};
void main()
{
    struct student n;
    struct student *s = &n;
    (*s).c = "hello";
    printf("%p\n%p\n", s, &n);
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
7
Which of the following uses structure?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
8
What is the order for the following C declarations?
short a : 17;
int long y : 33;
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
9
What will be the output of the following C code?
#include <stdio.h>
union u
{
    struct
    {
        unsigned char x : 2;
        unsigned int y : 2;
    }p;
    int x;
};
int main()
{
    union u u.p = {2};
    printf("%d\n", u.p.x);
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
10
Presence of loop in a linked list can be tested by . . . . . . . .
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board