C Language - Structures,Unions

You Are Here :: Home > C Language > Structures,Unions General Questions

 
43.

What is the output of this C code?

#include
struct student
{
char *c;
};
void main()
{
struct student s[2];
printf("%d", sizeof(s));
}

A. 2 B. 4
C. 16 D. 8




44.

What is the output of this C code?

#include
struct shalu
{
char *c;
};
void main()
{
struct shalu *s;
s->c = "hi";
printf("%s", s->c);
}

A. hi B. Segmentation fault
C. Run time error D. Nothing




45.

What is the output of this C code?

#include
struct move
{
char *c;
};
void main()
{
struct move m;
struct move *s = &m;
(*s).c = "front";
printf("%s", m.c);
}

A. Run time error B. Nothing
C. Varies D. front




46.

What is the output of this C code?

#include
struct p
{
int x;
int y;
};
int main()
{
struct p p1[] = {1, 2, 3, 4, 5, 6};
struct p *ptr1 = p1;
printf("%d %d\n", ptr1->x, (ptr1 + 2)->x);
}

A. 1 5 B. 1 3
C. Compile time error D. 1 4




47.

For the following declaration of structure, which of the following will stop the loop at the last node of a linked list?

struct node
{
struct node *next;
};

A. while (p != NULL)
{
p = p->next;
}
B. while (p->next != NULL)
{
p = p->next;
}
C. while (1)
{
p = p->next;
if (p == NULL)
break;
}
D. All of the mentioned




48.

What is the output of this C code?

#include
typedef struct student
{
char *a;
}stu;
void main()
{
stu s;
s.a = "bye";
printf("%s", s.a);
}s

A. Compile time error B. Varies
C. bye D. bye bye




« previous

1

2

3

4

5

6

7

8

9

...

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on