Primary or Fundamental Data Types: - Int - Float - Double - Char - Void
The document discusses different primary or fundamental data types in C programming including integer (int), floating point (float and double), character (char), and void. It provides details on the size and range of these data types for a 16-bit machine. It also explains qualifiers like long, short, signed, and unsigned that can modify the basic data types and alter their size or sign. Finally, it covers the void data type and how variables must be declared before use, stating the name and type.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
35 views13 pages
Primary or Fundamental Data Types: - Int - Float - Double - Char - Void
The document discusses different primary or fundamental data types in C programming including integer (int), floating point (float and double), character (char), and void. It provides details on the size and range of these data types for a 16-bit machine. It also explains qualifiers like long, short, signed, and unsigned that can modify the basic data types and alter their size or sign. Finally, it covers the void data type and how variables must be declared before use, stating the name and type.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13
Primary or Fundamental data types
All C compilers support five fundamental data types:
• int - integer: a whole number. • float - floating point value: a number with a fractional part. • double - a double-precision floating point value. • char - a single character. • void - valueless special purpose type which we will examine closely in later sections. Size and Range of Data types on a 16-bit machine Primary or Fundamental data types • Integers are whole numbers that can have both positive and negative values but no decimal values. Example: 0, -5, 10 • In C programming, keyword int is used for declaring integer variable. • Floating type variables can hold real numbers such as: 2.34, -9.382, 5.0 etc. • You can declare a floating point variable in C by using either float or double keyword. Difference among float, double and long double void data type
• The void type has no values.
• This is usually used to specify the type of functions. • The type of a function is said to be void when it does not return any value to the calling function. • Examples: void main (), void main (void) character data type
• A single character can be defined as a character (char) type
data. • Characters are usually stored in 8 bits (one byte) of internal storage. • The qualifier signed or unsigned may be explicitly applied to char. • unsigned char have values between 0 to 255 • signed char have values from -128 to 127 C Qualifiers: Size Qualifiers
• Size qualifiers alters the size of a basic type.
• There are two size qualifiers, long and short. • For example: long double i; • The size of double is 8 bytes. However, when long keyword is used, that variable becomes 10 bytes. • There is another keyword short which can be used if the programmer previously know the value of a variable will always be a small number. C Qualifiers: Sign qualifiers • Integers and floating point variables can hold both negative and positive values. • However, if a variable needs to hold positive value only, unsigned data types are used. • There is another qualifier signed which can hold both negative and positive only. However, it is not necessary to define variable signed since a variable is signed by default. • An integer variable of 4 bytes can hold data from -231 to 231-1. However, if the variable is defined as unsigned, it can hold data from 0 to 232-1. character data type Declaration of Variables • After designing suitable variable names, we must declare them to the compiler. • Declaration does two things: • It tells the compiler what the variable name is. • It specifies what type of data the variable will hold. • The declaration of variables must be done before they are used in the program. Declaration of Variables Declaration of Variables Declaration of Variables