Ask a question to Desklib · AI bot

# Write Programs Using Integer Numbers

| 2 pages
| 966 words
| 423 views

Trusted by 2+ million users,
1000+ happy students everyday

Coursework 1.1List processingIn this section you will be asked to write programs that ask from the user to enter a list ofinteger numbers (let us give the list name A) and then analyse the list as specified in thefollowing three subsections.In order to obtain the list A, the program first asks the user to enter the number ofelements of the list and then asks to enter these individual n elements in a loop lasting niterations (standard procedure of entering lists to be considered in the class of week 4).Let me stress again that this way of obtaining lists applies to all the three tasks below.Please feel free to assume that the input is entered correctly. No marks will be added forcorrectness checking of the input and, accordingly, no marks will be reduced for not doingsuch a check.1.1List containing the given set of elements (25 marks)Write a program that prints ”YES” if A contains numbers 1,2,3 (all of them) in an arbitraryorder and ”NO” otherwise. For instance, the program should print ”YES” if A =[10,2,4,15,3,6,1] and ”NO” if A = [1,17,2,45] (because number 3 is missing).1.2List containing the given set of elements in the given order (25 marks)Write a program that prints ”YES” if A contains all the numbers 1,2,3 occurring in the orderthey are listed (but not necessarily consecutive) and ”NO” otherwise. For instance theprogram prints ”YES” if A = [45,1,5,2,77,3] and ”NO” if A = [45,1,3,77,2] (incorrect order).Clearly, the program should also print ”NO” if one of 1,2,3 is missing in A.The tricky part of this task are cases of multiple occurrences of 1,2,3. For instance theprogram should print ”YES” if A = [3,2,1,2,3] because there are occurrences of 1,2,3appearing in the correct order while ”NO” should be printed for A = [3,3,2,2,1,2] becausethere are no such occurrences.The marking scheme for this exercise is the following.The solutions working for all cases (including repeated occurrences) will receive fullmark (25 marks).1The solution working only for cases without repeated occurrences of 1,2,3 will receive15 marks provided that the ‘NO REPEATED OCCURRENCES’ statement is explicitlyprovided as a comment to the program.The solutions working only for cases without repeated occurrences of 1,2,3 and notwarning the user about this in the comments will receive 5 marks.

## Found this document preview useful?

You are reading a preview
or
Become a Desklib member to get accesss

## Students who viewed this

### Support

#### +1-312 997 5479

Chat with our experts. we are online and ready to help.