Deadline Is 15 Jan 2021: Assignment 5
Deadline Is 15 Jan 2021: Assignment 5
Integer Arrays
Instructions:
Write a program that initialize array of size 10, and prints all Armstrong and Palindrome numbers in
array. Your program should ask user about their choice of printing. If user press ‘A’ or ‘a’ then program
should display all Armstrong numbers in array and if user press ‘P’ or ‘p’ then it should display all
Palindrome numbers in array.
Question # 2
Write a program that initialize an array of size 10. Create a generic code to shift array left and right. Your
program should be menu based, after each shifting show menu and array to user again and again.
Sample output
45 67 8 9 10 1 0 -1 2 98
****Menu*******
Press R or r for right shift
Press L or l for left shift
Press E or e for exit
L
67 8 9 10 1 0 -1 2 98 45
****Menu*******
Press R or r for right shift
Press L or l for left shift
Press E or e for exit
E
Question # 3
In a factory, different vehicles are being allocated different id. There are vehicles that have
same ids as well because they have loaded same material and are of same model. At check post
there are two list for maintaining the records of vehicle.
● In_list which consist of ids of vehicle that are present in factory.
● out_list contain the ids of vehicles that are about to come in factory.
Any vehicle from out_list will enter in factory when vehicle from In_list will go out of
factory.Write a program that ask user vehicle id which will go out and delete that entry from
In_list (if duplicate remove all entries and adjust array by back shifting as shown in example).
Take next entry from the out_list and put in the In_list. Remember Out_list does not have any
duplicate entries. Value from the out_list should be taken from index zero (then adjust array
shown in example)
In_list
25 89 10 11 5 11 26 39 68 25
out_list
Example:
Enter the vehicle you want to delete: 89
Intermediate step
In_list
25 10 11 5 11 26 39 68 25
out_list
Final output
In_list
25 10 11 5 11 26 39 68 25 128
out_list
Note: You can delete a vehicle until out_list becomes empty, no deletion can take place after it.