Given the following declaration and definition. Which anwer is incorrect syntax for pointer to structure?
struct temp{
int b;
}; struct temp * my_struct;
*my_struct.b = 10;
one of members of a structure can be a pointer to the same structure.
Yes
Which properly declares a variable of struct foo?
struct foo var;
Structures may contain variables of only one data type
False
Given a pointer to structure, it can access structure member elements using pointer – > operator.
True
what is the output of the following C program?
#include
12
The dot operator can be used to access the data stored in a strut variable
True
Which operator connects the structure name to its member name?
. (dot)
Members of different structures must have unique names
False
The correct syntax to access the member of the i-th structure in the array of structures is?
Assuming:
struct temp {
int b;
};
struct temp s[50];
s[i].b
what is the output of the following C program:
#include
alan alan alan turing
Observe the following program segment, and choose the appropriate printf() statement
from the options to print the value:
struct month
{
char *month;
};
int main()
{
struct month m={“March”};
—-
}
printf (“\n Month : %s”, m.month);
Which of the following operators can be applied on structure variables?
Assignment ( = )
A structure variable can be assigned to other using =, but cannot be compared with other using ==
Given the following program, choose the answer:
#include ‹stdio.h›
int main()
{
struct site
{
charname[] = “HKr web site”;
intno_of_pages = 200;
};
struct site *ptr;
printf(“%d “, ptr->no_of_pages);
printf(“%s”, ptr->name);
return 0;
}
Compiler Error
When we declare a structure or union, we actually declare a new data type suitable for our purpose. So we cannot initialize values as it is not a variable declaration but a data type declaration.
what is the output of the following C program:
#include
compilation error
what is the output of the following C program:
#include
alan
Given the following definition and declaration:
struct node
{
int i;
float j;
};
struct node *s[10];
An array, each element of which is a pointer to a structure of type node
what is the output of the following C program:
#include
newton alan alan
Given the following definition and declaration:
struct node
{
int i;
float j;
};
struct node *s[10];
An array, each element of which is a pointer to a structure of type node
It is possible to pass structure elements to function.
True
The member variable of a structure is accessed by using
dot (.) operator
What is the output of this C code?
#include
Compile time error
Bit fields provide the exact amount of bits required for storage.
True
pnt= (int *)calloc(4,2);
this statement allocates
4 blocks with 2 bytes each
Union have common storage space for all its members.
True
union test
{
int x;
char arr[8];
int y;
};
int main()
{
printf(“%d”, sizeof(union test));
return 0;
}
Predict the output of above program. Assume that the size of an integer is 4 bytes and size of character is 1 byte. Also assume that there is no alignment needed.
8
The enum keyword is used to define enumerated data type.
True
What will be the value of m displayed on execution of the following program?
struct bit
{
unsigned int m :3;
};
int main()
{
struct bit b={8};
printf (“\n m = %d”,b.m);
return 0;
}
m = 0
A memory leak happens when we allocate memory usingmalloc() and then free it using free().
False
The union holds
one object at a time
The function used to allocate the memory is
malloc()
The singly linked list is
moves forward only
Consider the following C declaration
struct{
short s[5];
union{
float y;
long z;
}u;
} t;
Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations
18 bytes