Unit I · Viva Questions
Revise the concepts orally; open a study answer when you need more detail.
Explain user-defined structure types, declaration and member access.
- Does defining a structure tag create a student object?
- No. A separate object declaration is needed unless combined with the definition.
- Why can a structure contain padding?
- The implementation can insert padding to meet alignment requirements.
Explain initialisation and input/output of structure members.
- Why is &s.roll used for numeric input?
- scanf needs the address of the int object it will fill.
- Is scanf %f suitable for a double member?
- No. Use %lf for double input.
Explain arrays of structures with a record-processing example.
- Which record does records[0] select?
- The first record.
- Does this maximum scan require sorting?
- No. One traversal is enough.
Explain nested structures and structures containing arrays or pointers.
- Does copying a structure duplicate a pointer’s target?
- No. It copies the pointer value.
- Is a nested Date object part of each Student object?
- Yes, when declared as an ordinary structure member.
Explain structures as input and output function parameters.
- What does the arrow operator select?
- A structure or union member through a suitable pointer.
- Does a const pointer-to-record parameter make the original object globally immutable?
- No. It prevents modification through that qualified access.
Explain functions that return structure values.
- Is returning &local the same as returning local?
- No. One returns an address and the other a value.
- Can a returned structure contain pointer members?
- Yes, but each target needs a suitable remaining lifetime.
Explain self-referential structures and their role in linked lists.
- What normally marks the end of a non-circular singly linked list?
- A NULL next link.
- Must linked nodes occupy adjacent memory?
- No.
Explain structure bit-fields, uses and limitations.
- Can &flags.ready be used?
- No. A bit-field has no address obtainable with &.
- Are bit-field packing rules identical on all C implementations?
- No.
Explain union types and contrast their storage with structures.
- Does writing a union member preserve all earlier member values?
- No. They share storage.
- Does C automatically update a separate tag field?
- No. The program must maintain the tag.
Compare structure and union types with suitable uses.
- Which type suits a record needing name and marks together?
- A structure.
- Can a structure contain a union?
- Yes. Tagged alternatives are a common example.
Explain typedef and its use with structures and pointers.
- Does typedef alone allocate a variable?
- No.
- Is typedef token replacement like a macro?
- No. It declares a type alias.
Explain enumeration types and their use as named states.
- What value follows RUNNING = 5 when DONE is unspecified?
- 6.
- Does an enum constant automatically print its spelling?
- No. A text mapping is needed.