Data Types 20210513173436
Data Types 20210513173436
Data Types 20210513173436
Data Types:
Data Types can be defined as the set of values which can be stored in a variable along with
the operations that can be performed on those values.
The main aim of C++ program is to manipulate data.
C++ data types can be classified as:
1. The fundamental data type(built-in data) - The simple or fundamental data types are the
primary data types which are not composed of any other data types. The simple data
types/fundamental data types include int, char, float, double and void.
2. Derived Data type -These data types are constructed using simple or fundamental data
types. This includes arrays, functions, pointers and references.
3. User-defined data type- These data types are also constructed using simple or
fundamental data types. Some user defined data types include structure, union, class and
enumerated.
2. Explain modifiers in detail. (U)
ANS : A modifier is used to alter the meaning of the base type so that it more precisely fits
the needs of various situations.
The data type modifiers are listed here −
signed
unsigned
long
short
The modifiers signed, unsigned, long, and short can be applied to integer base types. In
addition, signed and unsigned can be applied to char, and long can be applied to double.
The modifiers signed and unsigned can also be used as prefix to long or short modifiers.
For example, unsigned long int.
3. Explain enumerated data types with suitable examples (U)
ANS : An enumeration is a user defined type consisting of a set of named constants called
enumerators.
enum is a keyword that assigns values 0, 1, 2…… automatically.
This helps in providing an alternative means for creating symbolic constants.
The syntax for enum is as follows:
enum enum-type-name {value1, value2, value3…..valueN};
Example : enum choice { very_bad, bad, satisfactory, good, very_good};
choice mychoice;
4. What is a variable? Give its declaration. (K)
ANS : A variable is an object or element and it is allowed change during the execution of
the program.
Variable represents the name of the memory location.
The syntax for declaring a variable is:
datatype variable_name;
Here variable_name is an identifier.
5. Explain lvalue and rvalue with an example. (U)
ANS : Lvalue is the location value. It holds the memory address location at which the data
value is stored.
Rvalue is the data value. It holds the value assigned to the variable by the programmer.
Here values assigned to variable is 100 i.e. rvalue .Memory address location is 2000 i.e.
lvalue
6. What is a data type? Mention the different data types. (U)
OR
7. Explain the various data types. (U)
ANS :
Data Types:
Data Types can be defined as the set of values which can be stored in a variable along with
the operations that can be performed on those values.
The main aim of C++ program is to manipulate data.
C++ data types can be classified as:
1. The fundamental data type(built-in data) - The simple or fundamental data types are the
primary data types which are not composed of any other data types. The simple data
types/fundamental data types include int, char, float, double and void.
2. Derived Data type -These data types are constructed using simple or fundamental data
types. This includes arrays, functions, pointers and references.
3. User-defined data type- These data types are also constructed using simple or
fundamental data types. Some user defined data types include structure, union, class and
enumerated.
8. What are modifiers? Mention the different modifiers. (U)
ANS : A modifier is used to alter the meaning of the base type so that it more precisely fits
the needs of various situations.
The data type modifiers are listed here –signed, unsigned, long, short