


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information about quiz 2 for the cmsc 131 summer 2005 course, including instructions, exercise prompts, and examples. Students are required to write pseudocode for various programming problems, such as computing averages, determining decreasing sequences, generating multiplication tables, creating histograms, calculating atomic weights, and identifying increasing sequences.
Typology: Quizzes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



whether it is a decreasing sequence. A decreasing sequence is one where each value is greater than or equal to the next element in the sequence. The program will first read the number of values to process followed by the values in the sequence. The program will print the message " Decreasing " for a decreasing sequence and " Non-Decreasing " otherwise. For example, here are two decreasing sequences: 90 87 30 0 -1 - 110 4 0 - The following are non-decreasing sequences: 90 100 20 4 30 24 -2 -1 8 9
Write pseudocode for a program that reads a sequence of unique integer values and determines whether it is an increasing sequence. An increasing sequence is one where each value is greater than the preceding one. The sequence will be terminated by the special value -999, which is not considered to be part of the sequence. The program will print the message " Increasing " for an increasing sequence and " Non-Increasing " otherwise. For example, here are two increasing sequences: 2 45 90 134 -
Problem 6 One possible solution increasing = true prev = read() do { curr = read() if ( curr != -999 ) { if ( curr <= prev ) then increasing = false else prev = curr } while (increasing and curr != 999 ) if ( increasing ) then print(“Increasing”) else print(“Non-Increasing”) Problem 7 One possible solution sum = 0 number = read() curr = 0 while (curr < number) { x = read() if (curr is even) { _OR_ if (x is even) { sum += x } curr++ } print(sum)