Which of the following is not a primitive data type in C++?a)intb)stri...
The primitive data types in C++ are int, float, char, etc. However, string is not a primitive data type but a standard library class.
Which of the following is not a primitive data type in C++?a)intb)stri...
Explanation:
In C programming language, data types are divided into two categories: primitive data types and derived data types. Primitive data types are the basic building blocks of a program, while derived data types are created by combining primitive data types or other derived data types.
Primitive data types in C:
1. int: It is used to store integer values, both positive and negative, within a certain range. The size of an integer depends on the compiler and the system architecture.
2. float: It is used to store decimal values (floating-point numbers) with single precision. The size of a float is typically 4 bytes.
3. char: It is used to store a single character. It can also be used to represent small integers within a certain range. The size of a char is typically 1 byte.
Derived data types in C:
1. Array: It is a collection of elements of the same data type. It can hold multiple values of the same data type.
2. Structure: It is a user-defined data type that allows you to combine multiple variables of different data types into a single entity.
3. Union: It is similar to a structure but it can only hold one value at a time. All variables in a union share the same memory location.
4. Enum: It is a user-defined data type that allows you to define a set of named values. Each named value is assigned a unique integer value.
Answer:
The correct answer is option B - string.
In C, string is not a primitive data type. It is a derived data type that is created by combining an array of characters. A string is represented as a sequence of characters terminated by a null character ('\0'). To work with strings in C, you need to use character arrays and perform operations using string manipulation functions.
Summary:
In C programming, the primitive data types are int, float, and char. String is not a primitive data type in C, but a derived data type created by combining an array of characters.