Which of the following is a user-defined data type in c language?
(a) typedef int Boolean;
(b) typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
(c) struct {char name[10], int age};
(d) all of the mentioned
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Correct Answer: (d) all of the mentioned
In C programming, user-defined data types allow for greater flexibility and control over how data is stored and used in a program. This is achieved by creating a new data type using the keyword “typedef” and creating an alias for an existing data type. For example, a programmer can create a new data type “meters” for a distance variable by using the keyword “typedef” and aliasing the existing data type “float” to it. By using user-defined data types, code becomes more readable and understandable, and it also makes it easier to maintain and debug the program.
In C programming, a user-defined data type can also be created using the struct keyword. A struct is a user-defined data type that allows the programmer to group together different variables of different data types into a single unit, called a structure.
For example, a struct can be used to create a new data type “Student” which contains different variables such as name, age, and grade. The struct is defined by using the keyword “struct” followed by the structure name and curly braces containing the variables and their data types.