C Programming language

C Standard Library Function

Day 1: Introduction and brief history of C Programming language

Day 1: Advantages and Disadvantages of C, C Keywords, Data type modifiers in C

Day 1: Data types in C Programming language

Day 1: Secondary data types, Primitive and Non-primitive data types

Day 1: C Variables, C Constant, Format Specifiers in C

Day 2: Write first C program

Day 2: Flow of C program with example, main(), printf(), scanf()

Day 2: Operaters in C Programming language, Arithmetic operators

Day 2: Relational operators and Logical Operators in C Programming language

Day 2: Assignment, Increments and Decrement Operators in C Programming language

Day 3: Conditional statement: if else statement in C Programming language

Day 3: Conditional statement: switch statement in C Programming language

Day 3: Jump statements: return statement in C Programming language

Day 3: Jump statements: go to statement in C Programming language

Day 3: Jump statements: break statement in C Programming language

Day 3: Jump statements: continue statement in C Programming language

Day 4: Loops OR Iteration statement in C Programming language: for Loop

Day 4: Loops OR Iteration statement in C Programming language: while Loop

Day 4: Loops OR Iteration statement in C Programming language: do while Loop

Day 5: Array in C Programming language

Day 5: Access elements of Array in C Programming language

Day 5: One dimensional Array representation in memory using C Programming language

Day 5: Two dimensional Array representation in memory using C Programming language

Day 5: Multidimensional Array in C Programming language

Day 6: Function in C Programming language

Day 6: Definition, Declaration and Calling a Function in C Programming language

Day 6: Passing array to a function in C Programming language

Day 6: Calling Function in C Programming language : Call by value

Day 6: Calling Function in C Programming language : Call by reference

Day 6: Recursive Function in C Programming language

Day 6: Adding function to the library in C Programming language

Day 7: Pointer in C Programming language, How to use Pointer, Pointer declaration

Day 7: NULL Pointers in C Programming language

Day 7: Array of Pointers in C Programming language

Day 7: Pointer arithmetic in C Programming language

Day 7: Pointer to Pointer in C Programming language

Day 7: Pointer to Function in C Programming language: Passing pointers to functions

Day 7: Pointer to Function in C Programming language: Return pointer from functions

Day 8: Strings in C Programming language, Declaring String in C Programming language

Day 8: String functions in C Programming language

Introduction of Structure

Accessing the members of Structure

Structure With typedef Keyword and Use of sizeof function

Example of Structure

Dynamic memory allocation in C: Introduction

adplus-dvertising
Day 1 Data types in C Programming language
Previous Home Next

C has a concept of 'data types' which are used to define a variable before its use. A C programmer use appropriate data type as per his requirement. C supports various data types such as character, integer and float etc. All the data types are made up of units of memory called bytes. n order of size, starting with the smallest, the integer types are char, short, int, long. The smaller types take less memory, the larger types takes more space in memory.

# Integer Data Type

Integers are whole numbers with a range of values, Generally an integer occupies 2 bytes memory space and its value range limited to -32768 to +32768. To control the range of numbers and storage space, C has three classes of integer storage namely short int, int and long int. All three data types have signed and unsigned forms. Integer Data Types are denoted by int.

int <variable name>	/*	Syntax	*/

int num1;//  Range of short int is -32768 to -32767
short int num2;//  Range of short int is -128 to 127
long int num3;// Range of long integer is -2147483648 to 2147483647
signed int num4;// Range of signed int is -32768 to 32767
unsigned int num5;// Range of unsigned int is 0 - 65535.
unsigned long int num6;// Range of unsigned int is 0 to 4294967295.

Memory occupied by Integer

  • short int (1 Byte = 8 Bits)
  • int or signed int (2 Bytes = 16 Bits )
  • long int or signed long int (4 Bytes = 32 Bits)
Data typeKeyword Equivalent
Signed Integer signed int (or) int
Signed Short Integer signed short int (or) short int (or) short
Signed Long Integersigned long int (or) long int (or) long
Unsigned Integerunsigned int (or) unsigned
Unsigned Short Integerunsigned short int (or) unsigned short
Unsigned Long Integer unsigned long int (or) unsigned long

# Floating data types

The float data type is used to store fractional numbers (real numbers). Floating point numbers are denoted by the keyword float. The double is same as float but it takes double space (8 bytes) than float.

float  <variable name>	/*	Syntax	*/

float  num1;//  Range of float is 3.4 e-38 to 3.4 e+38
double  int num2;// Range of double is 1.7e-308 to 1.7e+308
long double int num3;// Range of long double is 3.4 e-4932 to 3.4 e+4932

Memory occupied by Float

  • float (4 Bytes = 32 Bits)
  • double (8 Bytes = 64 Bits)
  • long double (10 Bytes = 80 Bits)
Data typeKeyword Equivalent
Floating Point float
Double Precision Floating Point double
Extended Double Precision Floating Pointlong double

# Character data types

Character type variable can hold a single character. As there are singed and unsigned int (either short or long), in the same way there are signed and unsigned chars; both occupy 1 byte each, but having different ranges. Unsigned characters have values between 0 and 255, signed characters have values from –128 to 127. Character is declared by char.

char <variable name>	/*	Syntax	*/

char ch;	//  Range of char is -128 to 127
unsigned char name;	//  Range of unsigned char float is 0 to 255

Memory occupied by char

  • char or unsigned char (1 Byte = 8 Bits)
Data typeKeyword Equivalent
Character char
Unsigned Characterunsigned char

Some of the data types are with their range and how much space they required

Data Types Range Bytes Format
signed char-128 to + 1271%c
unsigned char0 to 2551%c
short signed int-32768 to +327672%d
short unsigned int0 to 655352%u
signed int-32768 to +327672%d
unsigned int0 to 655352%u
long signed int-2147483648 to +21474836474%ld
long unsigned int0 to 42949672954%lu
float-3.4e38 to +3.4e384%f
double-1.7e308 to +1.7e3088%lf
long double-1.7e4932 to +1.7e493210%lf
Previous Home Next