Input and Output of C++
Input and Output of C++
Input and Output of C++
Data types are means to identify the type of data and associated
operations of handling it.
C++ provides a predefined set of data types for handling the data it uses.
When variables are declared of a particular data type then the variable
becomes the place where the data is stored and data types is the type of
value(data) stored by that variable.
Data can be of many types such as character, integer, real etc. since the
data to be dealt with are of many types
DATA TYPES
DERIVED DATA TYPES
CHARACTER
WIDE CHARACTER
FUNDAMENTAL DATA
FLOAT
TYPES
VOID
INTEGER DATA TYPE..
2 bytes
Integers are whole numbers with a machine dependent range of values.
C has 3 classes of integer storage namely short int, int and long int. All of
these data types have signed and unsigned forms.
A short int requires half the space than normal integer values. Unsigned
numbers are always positive and consume all the bits for the magnitude of
the number. T
he long and unsigned integers are used to declare a longer range of values.
FLOAT DATA TYPE …
4 bytes
A number having fractional part is a floating- point number. An identifier
declared as float becomes a floating-point variable and can hold floating-
point numbers. floating point variables represent real numbers. They
have two advantages over integer data types:-
they have one disadvantage also, that is their operations are usually
slower.
DOUBLE DATA TYPE
…8 bytes
The data type double is also used for handling floating-
point numbers.
#include <iostream>
int main() {
// Extract length and width
cout << "Rectangle dimensions: ";
float Length;
float Width;
cin >> Length >> Width;
FLOATING-POINT
MODIFIERS
INTEGER TYPE MODIFIERS
signed: -2147483648 to
int Integer. 4bytes 2147483647
unsigned: 0 to 4294967295
signed: -2147483648 to
long int (long) Long integer. 4bytes 2147483647
unsigned: 0 to 4294967295
float Floating point number. 4bytes +/- 3.4e +/- 38 (~7 digits)
FUNCTIONS
REFERENCES
CONSTANTS
ARRAYS
An array is a series of elements of the same type placed in
contiguous memory locations that can be individually referenced
by adding an index to a unique identifier.
For example, we can store 5 values of type int in an array without
having to declare 5 different variables, each one with a different
identifier. Instead of that, using an array we can store 5 different
values of the same type, int for example, with a unique identifier.
Like a regular variable, an array must be declared before it is used.
A typical declaration for an array in C++ is:
type name [elements];
OUTPUT:- 12206
POINTERS
STRUCTURE
UNION
ENUMERATION
CLASS
class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2; ...
} object_names;
STRUCTURES
A data structure is a group of data elements grouped together under one
name. These data elements, known as members, can have different types
and different lengths.
union union_name {
member_type1 member_name1;
member_type2 member_name2;
member_type3 member_name3;
} object_names;
UNION
All the elements of the union declaration occupy the same physical
space in memory. Its size is the one of the greatest element of the
declaration.
C++ stmts
Control
stmt
If contin
If switch while do for break
ue
return
else