[go: up one dir, main page]

0% found this document useful (0 votes)
15 views16 pages

Data Types

The document provides an introduction to computer programming using the C language, covering topics such as the structure of a C program, variables, data types, and storage classes. It explains the importance of variables in storing data, the basic data types available in C, and the use of size, sign, and type qualifiers. Additionally, it discusses the number system and tools used in programming, including IDEs and debugging techniques.

Uploaded by

aggroups2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views16 pages

Data Types

The document provides an introduction to computer programming using the C language, covering topics such as the structure of a C program, variables, data types, and storage classes. It explains the importance of variables in storing data, the basic data types available in C, and the use of size, sign, and type qualifiers. Additionally, it discusses the number system and tools used in programming, including IDEs and debugging techniques.

Uploaded by

aggroups2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

23ECE105 COMPUTER PROGRAMMING

Prepared by,
Mrs. SUMITHRA R. P.
UNIT I

Introduction, structure of C program, variables, data types, storage classes, constants, enumeration
constant, keywords, operators, expressions, input/output statements, assignment statement
conditional statements;

Number system: binary, decimal, hexadecimal, conversion between number system types;

Introduction to tools – IDE, compilation, linking, debugging.


VARIABLE

A variable is an identifier for a memory location in which c data can


be stored and subsequently recalled.
Variables are used for holding data values so that they can be
utilized in various computations in a program.
Variables are a way of reserving memory to hold some data and
assign names to them so that we don’t have to remember the
numbers like 46735 instead we can use the memory location by
simply referring to the variable.
Every variable is mapped to a unique memory address.
 All variables have three important attributes.
❑ A data type that is established when the variable is defined, e.g.,
integer, real, character. Once defined, the type of a C variable
cannot be changed.
❑ A name of the variable
❑ A value that can be changed by assigning a new value to the
variable.
VARIABLE

 The C compiler generates an executable code which maps data


entities to memory locations. For example, the variable definition
int salary = 65000;
char name = ‘a’
float x = 2.3
DATA TYPES IN C
 The type, or data type, or a variable determines a set of values that a variable might take and a
set of operations that can be applied to those values.
DATA TYPES IN C

 C has five basic data types and they are as follows:


❖ character—Keyword used is char
❖ Integer—Keyword used is int
❖ floating point—Keyword used is float
❖ double precision floating point—Keyword used is double
❖ valueless—Keyword used is void
DATA TYPES IN C

 Sizes and ranges of basic data types in C for a 16-bit computer


DATA TYPES IN C

 Sizes and ranges of basic data types in C for a 32-bit computer


DATA TYPES IN C

 The void type has no values and only one operation, assignment.
 The void type specifies an empty set of values.
 It is used as the type returned by functions that generate no value.
 The void type never refers to an object and therefore, is not
included in any reference to object types.
DATA TYPES IN C

 The specifiers and qualifiers for the data types can be broadly classified into three types:
❑ Size specifiers— short and long
❑ Sign specifiers— signed and unsigned
❑ Type qualifiers— const, volatile and restrict.
 The size qualifiers alter the size of the basic data types.
 There are two such qualifiers that can be used with the data type int; these are short and
long.
Size specifiers

 sizes in number of bytes of the short int, int and long int data types in different
machines.
Sign specifiers

 "unsigned" in computer programming indicates a variable that can hold only


positive numbers.
 An unsigned variable type of int can hold zero and positive numbers
 "signed" in computer code indicates that a variable can hold negative and positive
values.
 a signed int holds negative, zero and positive numbers.
Type qualifiers

 Type qualifiers control how variables may be accessed or modified.


❑ const - They specify which variables will never () change
❑ volatile -This variables that can change unexpectedly ().
❑ restrict –This type qualifier allows programs to be written so that translators can
produce significantly faster executables.

You might also like