What are structures and unions? State differencves between them.



What are structures and unions? State differencves between them...

Answer / Pankaj Nsom

"Structures in C are user-defined data types that group multiple variables together, each of which may have a different type. A structure can be declared as: struct student { char name[30]; int roll_number; float marks; }; Unions in C allow a variable to occupy the memory space of another variable of a different type. Only one member of a union can store a value at any given time. They are useful when multiple data types need to be stored in the same memory location, but they share the same memory footprint."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

whats the use of header file in c?

2 Answers  


Write a program using bitwise operators to invert even bits of a given number.

2 Answers  


What is declaration and definition in c?

1 Answers  


How do we make a global variable accessible across files? Explain the extern keyword?

1 Answers  


what is a function prototype?

5 Answers  


what is the use of ‘auto’ keyword?

1 Answers  


I came across some code that puts a (void) cast before each call to printf. Why?

1 Answers  


What is the difference between if else and switchstatement

1 Answers  


Describe dynamic data structure in c programming language?

1 Answers  


void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s",env[i]); }

3 Answers  


One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

1 Answers  


what does keyword ‘extern’ mean in a function declaration?

1 Answers   Emerson,


Categories