What is the advantage of declaring void pointers?
When we do not know what type of memory address the pointer variable is going to hold, then we declare a void pointer for such.
Can we access the array using a pointer in C language?
Yes, by holding the base address of the array into a pointer, we can access the array using a pointer.
Where can we not use &(address operator in C)?
We cannot use & on constants and on a variable that is declared using the register storage class.
Write a simple example of a structure in C Language.
The structure is defined as a user-defined data type that is designed to store multiple data members of the different data types as a single unit. A structure will consume the memory equal to the summation of all the data members.
struct employee
{
char name[10];
int age;
}e1;
int main()
{
printf("Enter the name");
scanf("%s",e1.name);
printf("n");
printf("Enter the age");
scanf("%d",&e1.age);
printf("n");
printf("Name and age of the employee: %s,%d",e1.name,e1.age);
return 0;
}
What is a nested structure?
A structure containing an element of another structure as its member is referred to as a nested structure.
What is a self-referential structure?
A structure containing the same structure pointer variable as its element is called a self-referential structure.
Can the structure variable be initialized as soon as it is declared?
Yes, with respect to the order of structure elements only.
What is a union?
The union is a user-defined data type that allows storing multiple types of data in a single unit. However, it doesn't occupy the sum of the memory of all members. It holds the memory of the largest member only.
In a union, we can access only one variable at a time as it allocates one common space for all the members of a union.
Syntax of union:
union union_name
{
Member_variable1;
Member_variable2;
.
.
Member_variable n;
}[union variables];
Which variable can be used to access Union data members if the Union variable is declared as a pointer variable?
Arrow Operator( -> ) can be used to access the data members of a Union if the Union Variable is declared as a pointer variable.
What is an auto keyword in C?
In C, every local variable of a function is known as an automatic (auto) variable. Variables which are declared inside the function block are known as a local variable. The local variables are also known as auto variables. It is optional to use an auto keyword before the data type of a variable. If no value is stored in the local variable, then it consists of a garbage value.