5. Assignment 1
Provide a menu to manipulate or display the value of
variable of type t
Input:
6. Assignment 1
Provide a menu to manipulate or display the value of
variable of type t
Input: Integers N1 and N2
7. 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
12. 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
13. Examples:-
Step 3: Display the Menu 1.
1. Add element
2. Display element
3. Remove element
4. Exit from the program.
Assignment 1
15. 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
17. 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
19. 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
20. 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
22. Examples:-
Step 3.3: Remove element.
Is it possible to remove the elements?
Assignment 1
23. 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
24. 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
26. 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
27. Examples:-
Step 3.4: Exiting from the program.
Use exit 0 to come out of the program.
Assignment 1