0% found this document useful (0 votes)
46 views2 pages

Deadline Is 15 Jan 2021: Assignment 5

The document contains instructions for 3 programming assignments involving integer arrays: 1. Write a program to initialize an array of 10 numbers and print all Armstrong and palindrome numbers based on user input. 2. Write a program to initialize an array of 10 numbers and shift the array left and right based on user input, displaying the menu and shifted array each time. 3. Write a program to maintain two lists - one for vehicles currently in a factory and one for vehicles waiting to enter. The program should remove vehicles from the in-list and add vehicles from the out-list according to user input, handling duplicates and adjusting the arrays accordingly.

Uploaded by

Mian Adnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

Deadline Is 15 Jan 2021: Assignment 5

The document contains instructions for 3 programming assignments involving integer arrays: 1. Write a program to initialize an array of 10 numbers and print all Armstrong and palindrome numbers based on user input. 2. Write a program to initialize an array of 10 numbers and shift the array left and right based on user input, displaying the menu and shifted array each time. 3. Write a program to maintain two lists - one for vehicles currently in a factory and one for vehicles waiting to enter. The program should remove vehicles from the in-list and add vehicles from the out-list according to user input, handling duplicates and adjusting the arrays accordingly.

Uploaded by

Mian Adnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 5

Integer Arrays
Instructions:

 Submission on portal only


 Deadline is 15th Jan 2021
Question # 1

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

Array after shifting

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

128 69 13 512 120 100 21 69 56 0

Example:
Enter the vehicle you want to delete: 89

Intermediate step

In_list

25 10 11 5 11 26 39 68 25

out_list

128 69 13 512 120 100 21 69 56 0

Final output

In_list

25 10 11 5 11 26 39 68 25 128

out_list

69 13 512 120 100 21 69 56 0 -1

Note: You can delete a vehicle until out_list becomes empty, no deletion can take place after it.

You might also like