Difference between revisions of "CSC111 Exercises with For-Loops: Repeating things"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- <br /> =Exercise 1= <br /> Given the array sound sound = [ 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 9, 1, 1, 0, 0] write a program that will ask the user for a number a...")
 
(Exercise 2)
Line 16: Line 16:
 
  words = [ "hello", "there!", "there", "will", "be", "a", "big", "snow", "storm", "on", "Monday" ]
 
  words = [ "hello", "there!", "there", "will", "be", "a", "big", "snow", "storm", "on", "Monday" ]
  
write a program that will ask the user for a word and will indicate '''if this number is in the array''' or not
+
write a program that will ask the user for a word and will indicate '''if this word is in the array''' or not
 
<br />
 
<br />
 +
 
=Exercise 3=
 
=Exercise 3=
 
<br />
 
<br />

Revision as of 17:39, 28 February 2014

--D. Thiebaut (talk) 10:17, 28 February 2014 (EST)



Exercise 1


Given the array sound

sound = [ 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 9, 1, 1, 0, 0]

write a program that will ask the user for a number and will indicate if this number is in the array or not

Exercise 2


Given the array words

words = [ "hello", "there!", "there", "will", "be", "a", "big", "snow", "storm", "on", "Monday" ]

write a program that will ask the user for a word and will indicate if this word is in the array or not

Exercise 3


Same as Exercise 1, but this time the program returns the number of times the user choice appears in the array.

Exercise 4


Given the array sound, and an integer input by the user, your program will return the location of the first occurrence of the user's number.

Exercise 5


Given the array sound, and an integer input by the user, your program will return the location of the last occurrence of the user's number.