Data Types 20210513173436

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Chapter 8 Data types I PUC -CS

CHAPTER 8 DATA TYPES


One mark questions
1. Define a variable. (K)
ANS : A variable is an object or element and it is allowed change during the execution of the
program.
2. Give the syntax of declaring and initializing a variable. (K)
ANS :
The syntax for declaring a variable is: datatype variable_name;
The syntax to initialize a variable is: data_type variable_name = value;
3. Differentiate between lvalue and rvalue. (U)
ANS :
Lvalue (location value ) holds the memory address location at which the data value is
stored.
Rvalue (data value) holds the value assigned to the variable by the programmer .
4. Name the simple data types in C++. (K)
ANS : int, char, float, double and void
5. Write any two types of modifiers. (K)
ANS : Signed , unsigned, long , short
6. What are derived data types? Give example. (K)
ANS :
These data types are constructed using simple or fundamental data types.
Example: arrays, functions, pointers and references.
7. What are user-defined data types? (U)
ANS :
These data types are defined by user using simple or fundamental data types.
Example: structure, union, class and enumerated.
8. What is an enumerated data type? (K)
ANS :An enumeration is a user defined type consisting of a set of named constants called
enumerators.
9. Write the syntax for defining and declaring enumerated data type. (S)
ANS :
enum enum-type-name {value1, value2, value3…..valueN};
Two mark questions:
1. Explain data types and its classification. (U)
ANS :

Prepared by : Sanil Abraham, Deeksha Mahalakshmipuram Page 1


Chapter 8 Data types I PUC -CS

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)

Prepared by : Sanil Abraham, Deeksha Mahalakshmipuram Page 2


Chapter 8 Data types I PUC -CS

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

Prepared by : Sanil Abraham, Deeksha Mahalakshmipuram Page 3

You might also like