Team Emertxe
Advanced Pointers,Arrays
and Functions
Assignment 1
Assignment 1
Assignment 1
Provide a menu to manipulate or display the value of
variable of type t
Assignment 1
Provide a menu to manipulate or display the value of
variable of type t
Input:
Assignment 1
Provide a menu to manipulate or display the value of
variable of type t
Input: Integers N1 and N2
Assignment 1
Provide a menu to manipulate or display the value of
variable of type t
Input: Integers N1 and N2
Output: To provide a menu to display and manipulate the value
of variable type t
Examples:-
Assignment 1
Examples:-
 Step 1: Allocate 8 consecutive bytes in memory.
Assignment 1
Examples:-
 Step 1: Allocate 8 consecutive bytes in memory.
Assignment 1
0 1 2 3 4 5 6 7
Examples:-
Assignment 1
0 1 2 3 4 5 6 7
char short int/float
0 1 2 3 4 5 6 7
double
OR
Examples:-
 Step 2: Initialize 6 flags.
2 flags -> char
1 flag -> float
1 flag -> int
1 flag -> short
1 flag -> double
 Initialize all the flags to zero.
Assignment 1
Examples:-
 Step 3: Display the Menu 1.
1. Add element
2. Display element
3. Remove element
4. Exit from the program.
Assignment 1
Examples:-
 Step 3.1: Add element.
 Display Menu 2
1. int
2. char
3. float
4. double
Assignment 1
Examples:-
 Step 3.1: Add element.
 If user chooses ‘char’ type, read the character and store it in
0th index. Assume character ‘k’.
 After adding the character, make that respective flag to 1.
 Now, char_flag1 =1.
Assignment 1
k
0 1 2 3 4 5 6 7
char short int/float
Examples:-
Assignment 1
k
0 1 2 3 4 5 6 7
char short int/float
char_flag1 = 1
Examples:-
 Step 3.1: Add element.
 If user chooses ‘float’ type, read the floating number and store
it in 4th index. Assume number is 6.5.
 After adding the number, make that respective flag to 1.
 Now, float_flag1 =1.
Assignment 1
k 6.5
0 1 2 3 4 5 6 7
char short int/float
Examples:-
Assignment 1
0 1 2 3 4 5 6 7
char short int/float
float_flag = 1
k 6.5
char_flag1 = 1
Examples:-
 Step 3.1: Add element.
 If user chooses ‘int’ type, Assume 4.
 Print error message ‘Don’t have enough space to store’ because
float element is already present.
Assignment 1
k 6.5
0 1 2 3 4 5 6 7
char short int/float
Examples:-
 Step 3.2: Display element.
 Based on the flag values print the elements.
 If the flag value is 1, display the element.
 Here char_flag1 and float_flag is 1, so k and 6.5 will be
displayed.
Assignment 1
k 6.5
0 1 2 3 4 5 6 7
char short int/float
Examples:-
 Step 3.3: Remove element.
Assignment 1
Examples:-
 Step 3.3: Remove element.
Is it possible to remove the elements?
Assignment 1
Examples:-
 Step 3.3: Remove element.
 Is it possible to remove the elements?
No.
 So, for removing the elements, make the flag of particular
index to 0. Hence while displaying, those elements will not
displayed.
Assignment 1
Examples:-
 Step 3.3: Remove element.
 Read the index value to be deleted. Assume 0th index.
 Make the char_flag1 = 0.
Assignment 1
k 6.5
0 1 2 3 4 5 6 7
char short int/float
Examples:-
Assignment 1
0 1 2 3 4 5 6 7
char short int/float
float_flag = 1
k 6.5
char_flag1 = 0
Examples:-
 Step 3.2: Display element.
 Now only the float_flag is 1 so 6.5 will be displayed.
Assignment 1
k 6.5
0 1 2 3 4 5 6 7
char short int/float
float_flag = 1
char_flag1 = 0
Examples:-
 Step 3.4: Exiting from the program.
 Use exit 0 to come out of the program.
Assignment 1
Sample execution:-
Assignment 1
Sample execution:-
Assignment 1
Sample execution:-
Assignment 1
Sample execution:-
Assignment 1
Sample execution:-
Assignment 1
Sample execution:-
Assignment 1
Assignment 1
Pre-requisites:-
Assignment 1
Pre-requisites:-
⮚ Pointers
Assignment 1
Pre-requisites:-
⮚ Pointers
⮚ Dynamic Memory Allocation
Assignment 1
Pre-requisites:-
⮚ Pointers
⮚ Dynamic Memory Allocation
Objective:-
Assignment 1
Pre-requisites:-
⮚ Pointers
⮚ Dynamic Memory Allocation
Objective:-
⮚ To understand the concept of Dynamic Memory Allocation
Team Emertxe
Thank you

01_memory_manager.pdf