C language Data Types

C Language Data Types

Interview Questions on C language Data Types

1. What is Data Type?

Data type is a set of data with values having predefined characteristics such as integers and characters. Storage representations and machine instructions to handle data types differ from machine to machine.

2. How many data types are there in C?

C data types can be divided into three types:

1. Fundamental or Built-in data types (Primary Data Types).
2. Derived data types (Secondary Data Types).
3. User Defined data types.

3. What are the built-in data types in C?

The basic built-in or fundamental data types that are available in C are:
1. Int
2. Float
3. Double
4. Char

4. What is the use of int data type in C?

Int is used to define integer numbers. The size of data type ‘int’ is 2 bytes, or 16 bits. The minimum value for the signed ‘int’ data type is -32768.
The maximum value for the signed ‘int’ data type is 32767.
We can declare int data type as follows:
{
Int c;
C=5;
}

5. What is use of float data type in C?

Float is used to define floating point numbers. The size of data type ‘float’ is 4 bytes or 32 bits. The minimum and maximum value for the ‘float’ data type is 3.4E-38 to 3.4E+38.
We can declare float data type as follows:
{
float Miles;
Miles=5.6;
}

6. What is the use of double data type?

Double is used to define BIG floating point numbers. It reserves twice the storage for the number. On PCs this is likely to be 8 bytes. The size of data type double is 4 bytes or 32 bits. The minimum and maximum value for the ‘double’ data type is 1.7E-308 to 1.7E+308.
We can declare double data type as follows:
{
Double a;
A=2500;
}

7. What is the use of char data type?

Char defines characters. The size of data type char is 1 bytes or 8 bits. The minimum and maximum value for the ‘char’ data type is -128 to 127.
We can declare char data type as follows:
{
char Name
Name=’x’
}

8. What are data type qualifiers?

Data type qualifiers modify the behavior of variable type to which they are applied.

9. How many types of data type qualifiers are there in C?

Data type qualifiers can be classified into two types.

1. Size qualifiers.
2. Sign qualifiers.

10. What are Size qualifiers?

Size qualifiers alter the size of the basic data types. There are two size qualifiers that can be applied to integer: short and long. The minimum size of short int is 16 bit. The size of int must be greater than or equal to that of a short int. The size of long int must be greater than or equal to a short int. The minimum size of a long int is 32 bits.

11. What are Sign qualifiers?

The keywords signed and unsigned are the two sign qualifiers that specify whether a variable can hold both –ve and +ve numbers, or only +ve numbers. These qualifiers can be applied to the data types int and char only.

12. What are Derived Data Types?

Derived data types in C Programming Language are those C data types which are derived from the fundamental data types using some declaration operators.

13. How many types of Derived data types are there in C?

The basic derived types that are available in C are:
1. Array.
2. Functions and pointers.
3. Structures.
4. Classes etc.

14. Explain about Array derived data type?

The arrays can be defined as a set of finite and homogeneous data elements. Each element of an array is referenced using an index.
Example: If the name of an array is A which have 4 elements then the array will be represented as :
A[0], A[1], A[2], A[3].
Here, these subscripts which are containing the digit is known as an index.

15. Explain about Function derived data type?

Function can be defined as a part of the program which is declared by the programmer in any part of the program and a function can be of any name depending upon the choice of the programmer. The function declared can be invoked from other part of the program.

16. Explain about Pointer derived data type?

A pointer is a variable that holds the address of the memory space. If one variable can hold the address of the another variable then it is said that the first variable is pointing to the second.

17. Explain about structure derived data type?

Structure can be defined as a collection or a group of variables that are referenced under one name. It is used to keep related information together. We use a ‘struct’ keyword to construct a structure.

18. Explain about Class derived data type?

Class can be defined as a group of objects which are similar or of the same kind. The keyword ‘class’ is used to construct a class. A Class almost follows the same declaration procedure as we did in case of structures, but here comes the concept of access specifiers which applies a kind of restriction on the data. There are three types of access specifiers namely public, protected, and private.

19. What is User defined Data Type in C?

User can create his own data type for handling data that does not fit in one of the existing data types. Programmer can create an identifier that denotes an already existing data type with the help of a user defined data type. The programmer defined data type identifier is then used in a program to declare variables. In short its purpose is to redefine the name of an existing data type.
Syntax: typedef;

20. How many classes of user defined data types are there?

There are 2 classes of user defined data types.
1. Structure.
2. Enumeration.

21. What is Enum data type?

Enum data type is a user defined data type having finite set of enumeration constants. The keyword ‘enum’ is used to create enumerated data type.

Syntax:
Enum [data type] {const1, const2…., const n};

Follow me on social media: