6 views

Uploaded by Kaushal Kunal

notes

- 20461C_06
- Slide04-22 Midterm Review
- C#
- PPS QP
- BEST PRACTICE SHEET FOR NON PROGRAMMER
- Java All-In-One for Dummies Cheat Sheet - For Dummies
- Introduction to C
- datatypes_Variables
- Main
- Triggersdf
- Microsoft Visual Basic 6 (Basic Programming Fundamental)
- Arduino - Progmem
- cfitsio
- TP2 Lect05 01 Pointers
- Variables de Sistema FANUC
- Csharp Arrays
- Understanding the LENGTH statement in SAS data step.pdf
- Compiler Lab Index
- Post Processors - What's New in v9.pdf
- Java stuff

You are on page 1of 5

DATA TYPES

The C++ language is a strictly typed language, in this each variable, expression and

conversions are strictly or properly checked by the compiler. This feature of C++

helps us to reduce the errors in programming.

Data Types: To solve the problems of real word the programmer should deal with

different types of data. The data should be stored in the computer memory and it

should be processed. To represent the different types of data and to store in

computer memory, C++ has different data types.

Data Type: It is a type of the data using which different types of data can be

represented.

The data type gives the information about the type of data stored in the variable

and a set of operations can be performed with the data.

1. Fundamental (Built- In) Data type: In C++ there are 5 basic data types.

1) Integer: The keyword int is used to declare integers. The whole numbers

can be declared and stored using integers.

The general form of integer declaration is

int variable list;

Ex: int a, b;

Here a and b are variables of type integers in which a whole number can

be stored. The C++ allocates 4 bytes (32 bits) of memory for integer

data.

There are different types of integers

Short int: to store small integers, allocates 2 bytes of memory.

Long int: to store large numbers, allocates 8 bytes of memory

Unsigned int: to store positive numbers, stores the sign of the number

also.

2) Character: The keyword char is used to declare characters. The single

characters can be declared and stored using char data type.

8.DATA TYPES

char variable list;

char ch1, ch2;

Here ch1 and ch2 are character type of variables to store single

characters. The C++ allocates one byte (8 bit) of memory for char data.

The single characters are enclosed within the single quote.

3) Floating type: The keyword float is used to declare real numbers that is

the numbers with the fractional part. Small real numbers can be stored

using float.

The general form of float declaration is

float variable list;

float a, b;

Here a and b are variables used to store real numbers. C++ allocates 4

bytes (32 bits) for float data.

4) Double type: The keyword double is used to declare and store large

decimal numbers. The C++ allocates 8 bytes of space for double data.

The general form of double declaration is

double variable list;

double a, b;

Here a and b are the variables to store large real numbers.

5) Void type: This type of data type is normally used in function return

value or function arguments.

Void means empty or no values.

Ex: void output (void);

Here output () is a function which takes no arguments and returns no

value.

6) Boolean type: The keyword bool is used to declare Boolean type of

data. These stores either true or false that is 1 or 0. C++ allocates 1 bit of

space for this type of data. This is used in evaluating the expressions.

The general form of Boolean type is

bool variable list;

Ex: bool male;

8.DATA TYPES

2. Derived Data type: The data types created using fundamental types are

called as derived data types. Derived data types of C++ are

1) Arrays

2) Functions

3) Pointers

4) References

3. User Defined Data type: The data type created using fundamental types

according to the requirements of the user is called as user defined data

types. They are

1) Classes

2) Structures

3) Unions

4) Enumerations

1. Variables: A meaningful name given to a data storage location in computer

memory.

Syntax: data type variable name list;

That is

Data type v1, v2,…..vn;

Depending on the type of the variable declared, the computer will assign

the number of bytes to that variable.

Ex: int num; Here num is a variable of type integer. The computer will

assign 4 bytes of memory for int variable.

The memory address of num variable can be accessed using &num, &

operator gives the address of the variable.

To assign the value to the variable, the syntax is

Variable name=value;

Ex: int a;

a=10;

char ch;

ch=’y’;

Expressions: An expression in C++ is a valid combination of operators and

operands.

8.DATA TYPES

OR

An arrangement of identifiers, literals and operators that can be evaluated

to compute a value.

The types of expressions are

1. Arithmetic Expression: It is a valid combination of arithmetic operators

and operands.

There are three types

1) Integer Mode: These expressions are formed using integer values,

constants and arithmetic operators.

Ex: 20+7, 20/5 etc.

2) Real Mode: These expressions are formed using real values,

constants and arithmetic operators.

Ex: 9.8+7.6, 25.0/5.0 etc

3) Mixed Mode: These expressions are formed using real and integer

values, constants and arithmetic operators.

Ex: 25/5.0, 7%5+10 etc

2. Relational Expression: It is a valid combination of relational operators

and operands. These expressions evaluate to true or false value.

Ex: 3<7, 21>=10 etc

3. Logical Expression: It is a valid combination of relational operators,

logical operators and operands. Using logical operators, multiple

conditions can be checked.

Ex: if (marks>=35) && (marks<=100)

(a>b) || (b>c)

specific order. This is known as precedence of operators.

Ex: 5*6+8, in this * has the more precedence so multiplication operation

has performed first and then the addition.

So, 5*6=30+8=38

Declaring Constants: Constant is a variable whose value remains fixed

through out the execution of the program.

const data type identifier =3.145;

IPUC COMPUTER SCIENCE Page 4

8.DATA TYPES

Order of applying operators:

1. Evaluate any expression enclosed in parentheses.

2. Evaluate the expression which involves multiplication and division

operation, if multiplication and division comes together then evaluate

from left to right.

3. Evaluate the expressions which involve addition and subtraction

operation. If addition and subtraction comes together evaluate from left

to right.

Ex: 10-25+5 here the expression 10-25 will be evaluated first and then

-15+5 will be evaluated.

Ex: 12*10/2 here the expression 12*10 will be evaluated first and then

22/2 will be evaluated.

- 20461C_06Uploaded bydfrr2000
- Slide04-22 Midterm ReviewUploaded byWil Arz
- C#Uploaded byManish Kumar Aery
- PPS QPUploaded byAkhil
- BEST PRACTICE SHEET FOR NON PROGRAMMERUploaded byNavin Kumar
- Java All-In-One for Dummies Cheat Sheet - For DummiesUploaded byVlad Mihalachita
- Introduction to CUploaded bySufia Khanam
- datatypes_VariablesUploaded byapi-26891935
- MainUploaded byrmccloskey8
- TriggersdfUploaded byRidwan Wibowo
- Microsoft Visual Basic 6 (Basic Programming Fundamental)Uploaded byAbdul Majeed Khan
- Arduino - ProgmemUploaded bydattarider
- cfitsioUploaded byNarsi Reddy
- TP2 Lect05 01 PointersUploaded byDebrah Debbie
- Variables de Sistema FANUCUploaded byLakisha Blevins
- Csharp ArraysUploaded bySenthil Murugan
- Understanding the LENGTH statement in SAS data step.pdfUploaded byptscrib
- Compiler Lab IndexUploaded byvasanth
- Post Processors - What's New in v9.pdfUploaded byxuanphuong2710
- Java stuffUploaded byGeorgescu Razvan
- ArraysUploaded byForkenstein
- BufferedOutputStream (Java Platform SE 7 )Uploaded bypcdproyecto
- CS1 String MethodsUploaded byAbhishekPrajapati
- Assessments.pdfUploaded byveronica
- Data TypesUploaded byRaghavendra Rajendra Basvan
- SysTypes V3x EUploaded bymuhamad.badar9285
- Jason GawapoUploaded byLyrr Rosil
- datastructure.docxUploaded bySuman Kumari
- r androidUploaded bysatish
- brutalassmasterUploaded bySteven Gaines

- Digital Logic DesignUploaded bynayab
- Complete TutorUploaded by2faan
- Department+and+English+Information(Ewha)Uploaded byGilson Júnior
- Algebra Homework Set 7 Hung Tran. 8.3.11 (⇒) Suppose RUploaded bythp343
- The Wonders of Mathematics Ambassador Subir Kumar Bhattacharyya John Keats’Uploaded byapi-15379927
- Le Bon, Gustave - The Evolution of Forces (en, 1908, 438 S., Text)Uploaded byjosé_santos_103
- Mental MathUploaded byvickytatkare
- 1708.03486Uploaded bychew20
- Syllabus 2419 CalcIIUploaded byamirthebulldozer
- Trapezoidal RuleUploaded byJairus Samuel
- matthias-slides.pdfUploaded byakr_659
- npsD49EUploaded byneversaynever99
- Geometry ReviewUploaded byRocket Fire
- Study Unit 2.1 Basic ProbabilityUploaded bybronwyncloete
- Pre-Algebra_student-parent_study_guide.pdfUploaded byjohnsonkk125
- Vissarion Papadopoulos, Dimitris G. Giovanis-Stochastic Finite Element Methods. an Introduction-Springer (2018)Uploaded byJohnny Renato Quispe
- Mathematical ReasoningUploaded byRatih Ayu Kusumasari
- Colon classificationUploaded byCuriousLibrarian
- (Advanced Series on Theoretical Physical Science 9) Jong-Ping Hsu (ed.), Dana Fine (ed.)-100 Years of Gravity and Accelerated Frames_ The Deepest Insights of Einstein and Yang-Mills-World Scientific (.pdfUploaded byΜάριος Αθανασίου
- Theory and Anlysis of Nonlinear Framed Structures - Y. Bin Yang.pdfUploaded byAllan Gavino
- Airy Stress FunctionUploaded bythoitrung76
- R5210402 Probability Theory & Stochastic ProcessesUploaded bysivabharathamurthy
- Multi Phase Reacting Flow by MarchisioUploaded byakostin
- AN APPLICATION OF THE GENERALIZATION OF CEVA’S THEOREMUploaded byDon Hass
- POLARIZed Fractal EfficiencyUploaded bykgsbpp
- Passive VocabularyUploaded bysami
- AnswersUploaded byAlyssa L
- StatisticalModeling2culturesUploaded byinvisible_in
- geomentryUploaded byrajap81
- Non Parametric TestsUploaded byRohit Vishal Kumar