C-Structure & Union Question and Answer
C-Structure & Union Question and Answer
41. Find the output.
void main ( )
{
struct
{
char name [10];
int age;
}abc;
static struct abc={"raja", 15};
printf("%s %d, abc.name, abc. age);
}
void main ( )
{
struct
{
char name [10];
int age;
}abc;
static struct abc={"raja", 15};
printf("%s %d, abc.name, abc. age);
}
- raja 15
- 0 0
- Garbage output
- Compilation error
42. Find the output
void main ( )
{
struct st
{
char x[10];
char *ptr;
};
struct st s={"puri","cuttrack"};
print ("%c%c",s.x[0], s.ptr[0]);
printf("%s %s", s.x.s.ptr);
}
void main ( )
{
struct st
{
char x[10];
char *ptr;
};
struct st s={"puri","cuttrack"};
print ("%c%c",s.x[0], s.ptr[0]);
printf("%s %s", s.x.s.ptr);
}
- p cpuri cuttack
- puri cuttack puri cuttack
- Garbage Garbage puri cuttack
- None of these
43. Find the output
typedef struct {
int roll;
char name[15];
}student;
void main ( )
{
student s1, s2;
s2=s1={10, "Raja"};
printf("%d%s", s2.roll, s1.name);
}
typedef struct {
int roll;
char name[15];
}student;
void main ( )
{
student s1, s2;
s2=s1={10, "Raja"};
printf("%d%s", s2.roll, s1.name);
}
- 10 raja
- Garbage Raja
- compilation error
- Noneo of these
44. Find out the odd one
- The disadvantage of using bit fileds lies in the lack of portability.
- The address operator &, cannot be used with bit fields
- Bit fields can be specified in a structure declaration without a name.
- None of these
45. Find the outpu
struct emp
{
int eno;
char name[10];
};
void main ( )
{
struct emp e1={121, "Rama"};
struct emp e2={122, "Dama'};
if(e1==e2)
printf("Same");
else
printf("Different");
}
struct emp
{
int eno;
char name[10];
};
void main ( )
{
struct emp e1={121, "Rama"};
struct emp e2={122, "Dama'};
if(e1==e2)
printf("Same");
else
printf("Different");
}
- same
- Different
- Compilation error
- None of these
46. Find the output
struct byte
{
int i:9;
int b:5;
int c;
char ch;
};
void main ( )
{
struct byte b;
printf("%d", sizeof(b));
}
struct byte
{
int i:9;
int b:5;
int c;
char ch;
};
void main ( )
{
struct byte b;
printf("%d", sizeof(b));
}
- 5
- 7
- 6
- None of these
47. Find the outpu
void main ( )
{
struct stu
{
int roll;
char name [10];
};
struct stu s={10, "Tuni"};
call (s);
}
call (struct stu s)
{
printf ("%d%s", s.roll, s.name);
}
void main ( )
{
struct stu
{
int roll;
char name [10];
};
struct stu s={10, "Tuni"};
call (s);
}
call (struct stu s)
{
printf ("%d%s", s.roll, s.name);
}
- 10 Tuni
- Compilation error
- Runtime Error
- None of these
48. Find the output
struct std
{
int code;
char place [10];
};
void fain (struct std);
void main ( )
{
struct std s={80,"bang");
fain (s);
printf("%d", s.code);
}
void fain (struct std s)
{
s.code++;
}
struct std
{
int code;
char place [10];
};
void fain (struct std);
void main ( )
{
struct std s={80,"bang");
fain (s);
printf("%d", s.code);
}
void fain (struct std s)
{
s.code++;
}
- 80
- 81
- Compilation error
- None of these
49. The memory allocated for union is internally done through
- malloc()
- calloc()
- farmalloc()
- None of these
50. The memory allocated for union is internally done through
- Malloc()
- calloc()
- farmalloc()
- None of these