C-Structure & Union Question and Answer
C-Structure & Union Question and Answer
31. Find the output
struct kkk
{
char a:4;
char b:4;
char c:1;
int e:2:
};
struct kkk k,s={16, 16, 1, 4};
void main ( )
{
k =s;
printf ("%d %d", k.a, k.c);
}
struct kkk
{
char a:4;
char b:4;
char c:1;
int e:2:
};
struct kkk k,s={16, 16, 1, 4};
void main ( )
{
k =s;
printf ("%d %d", k.a, k.c);
}
- 16 1
- 0 1
- 0 -1
- None of these
32. Find the output
#defne int char
#define char int
struct student
{
char name [10];
int roll;
};
void main ( )
{
struct student s;
printf("%d", sizeof (s);
}
#defne int char
#define char int
struct student
{
char name [10];
int roll;
};
void main ( )
{
struct student s;
printf("%d", sizeof (s);
}
- 12
- 11
- 21
- 22
33. Find the output
struct x
{
char y;
int x;
};
void main ( )
{
struct xx s={'a', 15};
switch (s)
{
case 'a':
printf("Allowed");
break;
case 15:
printf("Not allowed");
break;
default:
printf ("No");
}
}
struct x
{
char y;
int x;
};
void main ( )
{
struct xx s={'a', 15};
switch (s)
{
case 'a':
printf("Allowed");
break;
case 15:
printf("Not allowed");
break;
default:
printf ("No");
}
}
- Allowed
- Not allowed
- No
- Compilation error
34. Find the correct output
#incoude "stdio.h"
void main ( )
{
printf("%d", stdin->bsize);
}
#incoude "stdio.h"
void main ( )
{
printf("%d", stdin->bsize);
}
- 256
- 512
- 1024
- None of these
35. Find the output
struct xyz
{
int x;
char y[5];
};
void main ( )
{
struct xyz m;
m.x=10;
m.y="raja";
printf("%d %s", m.x, m.y);
}
struct xyz
{
int x;
char y[5];
};
void main ( )
{
struct xyz m;
m.x=10;
m.y="raja";
printf("%d %s", m.x, m.y);
}
- 10 raja
- 10 garbage
- Erro, Ivalue required
- None of these
36. What is the output of the following program if you press 'z' then 'a' in keyboard
void main ( )
{
char ch;
while ((ch=getche( ))==="z");
printf("%c", ch);
}
void main ( )
{
char ch;
while ((ch=getche( ))==="z");
printf("%c", ch);
}
- z
- zz
- zaa
- zza
37. State the true statement.
- Bit-fields are allocated from left to right.
- A bit-field shall cross its unit boundary.
- Complex data types can be created using nested stucture.
- All of the above
38. Find the correct output
void main
{
struct xxx
{
char c[10]='CITE";
int i=2001;
};
struct xxx a;
printf('%s', a.c);
}
void main
{
struct xxx
{
char c[10]='CITE";
int i=2001;
};
struct xxx a;
printf('%s', a.c);
}
- CITE
- C
- Compilation error
- None of these
39. Find the output
struct student
{
int roll;
char name [10];
char city [10];
};
struct student s={10,"milan","puri"}*p;
void main ( )
{
p=*s;
p->roll=20;
p->name=s.city;
printf("%d %s %s", s.roll, s.name, p->city);
}
struct student
{
int roll;
char name [10];
char city [10];
};
struct student s={10,"milan","puri"}*p;
void main ( )
{
p=*s;
p->roll=20;
p->name=s.city;
printf("%d %s %s", s.roll, s.name, p->city);
}
- 10 milan puri
- 20 puri puri
- 20 milan puri
- Compilation error
40. Which of the following is limitation of bit filed?
- Bit fileds do not have addresses.
- Bit fields cannot be read using scanf() function.
- They cannot store values beyond their limits.
- All of the above