You can Download Chapter 8 Data Types Questions and Answers, Notes, 1st PUC Computer Science Question Bank with Answers Karnataka State Board Solutions help you to revise complete Syllabus and score more marks in your examinations.
Karnataka 1st PUC Computer Science Question Bank Chapter 8 Data Types
1st PUC Computer Science Data Types One Mark Questions and Answers
What is meant by data types?
The set of values along with the operations that can be performed on these values are called as data types.
Give the classification of data types.
Data types are classified into built-in or basic data types and user-defined or derived data types.
Name the built-in data types of C++.
The built-in or basic data types supported by C++ are integer, floating-point, and character types.
How is derived data type created?
The derived data type is created by using basic data types.
What is linear data structure?
When data elements are arranged in a sequential manner it is called as linear data structure.
What is a non-linear data structure?
When the data elements are arranged non-sequentially it is called as non linear data structure.
Give the range of values that int data type can store.
The range of values that int data type can store is from -32768 to 32767.
Give the ‘char’ data type range of values.
The ‘char’ can store 256 characters in the range of-128 to 127.
Give the storage size of the float data type.
The float data type needs 4 bytes of memory for each number with a fractional part.
The modifiers change the meanings of the predefined built-in data types and expand them to a much larger set.
Write the different modifiers.
The different modifiers are long, short, signed and unsigned.
What is the range of values that unsigned int can store?
The range of values that unsigned int stores is 0 to 65535.
Give the unsigned char range of values.
The unsigned char can store the value in the range of 0 to 255.
Mention a few user-defined data types.
A few user-defined data types are structure, union, class and enumerated data types.
What is an enumerated data type?
An enumerated type is a data type where every possible value is defined as a symbolic constant (called an enumerator).
1st PUC Computer Science Data Types Two/Three Marks Questions and Answers
What are the variables? Give an example.
It is a location in the computer memory which can store data and is given a symbolic name for easy reference.
For example, Total = 20.00; In this statement, a value 20.00 has been stored in a memory location Total.
Give the declaration syntax of a variable and example.
The syntax for declaring a variable is
- datatype variablename;
- example, on
variable initialized? Give an example.
The variable is initialized during declaration of the variable with initial value.
For example, int a = 20;
Explain lvalue and rvalue. Give a examples.
Lvalue is the location value and r value is the data value of a variable.
int age =16;
lvalue is the location value of age and 16 is the r-value.
What is dynamic initialization? Give its advantage.
It is a method of initialization C++ adopts. In this method, C++ declares a variable during the run time of the program. The advantage is variables can be initialized anywhere in the program before they are used.
Write the features of int data type.
Integers are those values which have no decimal part and they can be positive or negative, like 12 or-12.
- int keyword is used for integers.
- It takes two bytes in memory.
There are two more types of int data type
- signed int or short int
- unsigned int or unsigned short int.
Give the features of char data type.
C++ offers a predefined data type that is one byte in size, which can hold exactly one character such as ‘a’ or ‘A’.
To declare a variable of type char,
Write the features of the float data type.
C++ defines the type float data as representing numbers that have a fractional part. For example, 12.55. Floating-point variables can either be small or large. A variable with float type occupies 4 bytes in size and can hold numbers from 10-308 to 10+308 with about 15 digits of precision. There is a long double, also available, that can hold numbers from 10-4932 to 10+4932.
What is a void? Give the usage.
The data type void has no values and no operations means it is empty. It plays the role of generic data type and can represent any of the other standard types. It is also used in functions which do not return any value.
Explain bool data type.
The bool data type means Boolean, that has the logical value true or false. It can be used to manipulate logical expressions.
What is named constant? Give the declaration.
The named constant is a memory location, whose value cannot be changed during the execution of a program.
const datatype variable = initial value;
What are the conversion rules for enum type?
There is an implicit conversion from any enum type to int. It does not support for implicit conversion from into to enum type.
1st PUC Computer Science Data Types Five Marks Questions and Answers
Write a short note on variables.
“A variable is a temporary container to store information, it is a named location in computer memory where varying data, like numbers and characters, can be stored and manipulated during the execution of the program”.
A variable must be declared before it is used.
For example, int my_age;
A few naming conventions must be taken in consideration.
- It must start with an english alphabet character, either lowercase or uppercase, including underscore (not a hyphen). It may not start with a digit. The rest is optional. It can either be a letter or a digit (0-9).
- C++ keywords like main, case, class, if, else, do, while, for, tyedef, etc cannot be used as a variable names.
- It must be unique within the scope.
Explain the basic data types in details.
In computer programming, information is stored in a computer memory with different data types. We must know what is to be stored in a computer memory, whether it is a simple number, a letter or a very large number.
Basic Data types in C++
C++ offers a predefined data type that is one byte in size, which can hold exactly one character such as ‘a’ or ‘A’. To declare a variable of type char, we have
Suppose we want to store a character value ‘a’, in a char data type eh, it is enclosed within a single quote.
ch = ‘a’;
Only a single character can be stored in a variable of type char.
On most machines, the size of int type is 2 bytes. C++ defines this type as consisting of the values ranging from -32768 to 32767. This range is for the small integer. If a long integer is needed, the type long or long int can be used. The range of long int is too big that is from -2147483648 to 2147483647, which occupies 4 bytes in memory.
C++ defines the data type float, as representing numbers that have a fractional part. For example, 12.55 as opposed to integers which have no fractional part. Floating-point variables can either be small or large. A variable with type float occupies 4 bytes in size and can hold numbers from 10-308 to 10+308 with about 15 digits of precision. There is a long double, also available, that can hold numbers from 10-4932 to 10+4932.
It is an additional data type for representing a Boolean value. A variable associated with a bool data type may be assigned an integer value 1 to the literal true and a value 0 to the literal false.
Write a short note on modifiers.
C++ allows the char, int, and double data types to have modifiers preceding them. A modifier is used to alter the meaning of the base type so that it more accurately fits the needs of various situations.
The data type modifiers are listed here:
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.
C++ allows a shorthand notation for declaring unsigned, short, or long integers. You can simply use the word unsigned, short or long, without the int. The int is implied. For example, the following two statements both declare unsigned integer variables, unsigned x; unsigned int y;
Write the different data types, memory size in bytes, minimum value, maximum value
Data types in C++