data types
DESCRIPTION
TRANSCRIPT
![Page 1: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/1.jpg)
DATA TYPESIn C\C++ , data are mainly divided
into three different types. These are:1. Character type data
2. Integer type data 3. Real data type
![Page 2: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/2.jpg)
1. Character data type:Characters (letters, digits and punctuation character)
Are represented by the “char” data type. The “short” data type is the same size as “ char” ,usually one byte.
![Page 3: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/3.jpg)
Character data type:
Character data type must be signed and unsigned (either short or long). Both occupying one byte each, but have different ranges. To begin with, it might appear strange as to how a char can have a sign. Consider the statement
Char ch=‘A’Char ty=‘B’Char ze=‘D’ etc.
![Page 4: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/4.jpg)
Character data type:A signed char is same as an ordinary char
and has a range from -128 to +127: where as, unsigned char has a range from 0 to 255. let us now see a program below
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
Void main()
{
Char ch=291;
Printf(“\n%c”,ch);
Getch();
}
![Page 5: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/5.jpg)
2. Integer data type:Integer data type (whole numbers) are
represented by “int”.Some time, we know in advance that the
value stored in a given integer variable will always be positive when it is being used to only count things.
We can declared it as below.Int a=20;Int b=40;
Int c=30; etc
![Page 6: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/6.jpg)
3: Float data type:Those number which are in decimal fraction
are represented by “float”.We can show float numbers in printf
statement of C\C++ by “%f”.Float number are declared asFloat a=“40.00”
Float b=“23.04”
Float c=“10.3” etc
![Page 7: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/7.jpg)
Float data type:We can write a program as:#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
Void main()
{
Float a=29.1;
Printf(“\n%f”,a);
Getch();
}
![Page 8: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/8.jpg)
Integer data type:We can write a program in C\C++ are as
shown below.#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
Void main()
{
Int a=291;
Printf(“\n%d”,a);
Getch();
}
We can show the integer data type in C|C++ by “%d” in printf statement.
![Page 9: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/9.jpg)
CONSTANTS:Unlike variable, a constant is a fixed value
that does not change during the execution of program. We can say that constant is a values while variable are holders of these values. In C|C++, a constant may be divided into main two types.
1. Numeric constant.2. Non-numeric constant.
![Page 10: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/10.jpg)
NUMERIC CONSTANT:Numbers are referred to as numeric
constants. Numeric constants are used for numeric purposes. It contain:
Numeric digits 0 to 9.Plus(+) or minus(-) signs.Decimal pointsIt is important to that note no commas or
blanks are allowed in numeric constants.
![Page 11: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/11.jpg)
In C|C++, numeric constant can be represented in three ways.
Integer constantFloating constantExponential real constant
![Page 12: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/12.jpg)
![Page 13: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/13.jpg)
OCTAL INTEGER CONSTANT:In C|C++ , any integer constant with a
leading 0, is interpreted as Octal constant an octal constant is a base 8 numbers system and valid digits in octal system are only 0 through 7. it is important to note that in C|C++ , decimal integer constant cannot start with a leading 0.
![Page 14: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/14.jpg)
HEXADECIMAL INTEGER CONSTANTIn C\C++ any integer constant, which begins
with 0x or 0X, is interpreted as hexadecimal integer constant. An hexadecimal constant is a base -16 number and valid digit in hexadecimal system are 0 through 9,A,B,C,D,E and F.
![Page 15: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/15.jpg)
FLOATING POINT CONSTANT:The numeric constant, which does not
contain a decimal point is known as floating point constant. Like integer constant, floating points could either be positive or negative.
![Page 16: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/16.jpg)
NON NUMERIC CONSTANT:Non numeric constant are used for non
numeric purposes. Such as to produce output reports, heading or printing messages etc, non numeric constant are divided into two types.
Character constantString constant
![Page 17: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/17.jpg)
EXPONENTIAL REAL CONSTANT:Floating point constant can also be
represented in the E-notation form, and this type of numeric constant is known as exponential real constant.
![Page 18: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/18.jpg)
CHARACTER CONSTANT:In C\C++, character constant are enclosed
within single quotes. It is important to note that the single quotes are not part of the character constant, but they serve to delimit it.
![Page 19: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/19.jpg)
STRING CONSTANT:Any character or sequence of character
between double quotes is known as string constant or simply a string.
![Page 20: Data types](https://reader036.vdocument.in/reader036/viewer/2022082623/54581346af7959de728b65c3/html5/thumbnails/20.jpg)
ZAHID HUSSAINClass no : 322Subject : Data types, ConstantsShift : EveningSubmitted to UMAR ALI SIR