Preceded by the VIC-20 and Commodore PET, the C64 took its name from its 64 kilobytes (65,536 bytes) of RAM. Volume production started in early 1982, marketing in August for US$595 (equivalent to $1,800 in 2022). It has been listed in the Guinness World Records as the highest-selling single computer model of all time, with independent estimates placing the number sold between 12.5 and 17 million units. ** Doubles the first 5 elements of the array */įor (int i = 0 i < values.The Commodore 64, also known as the C64, is an 8-bit home computer introduced in January 1982 by Commodore International (first shown at the Consumer Electronics Show, January 7–10, 1982, in Las Vegas). What will the following code print out? Can you write a similar method called tripleFirstFour() that triples the first 4 elements of the array? Make sure you test it in main. It is created in the constructor and changed or accessed by the methods. Notice that it uses a complex conditional ( &) on line 14 to make sure that the loop doesn’t go beyond the length of the array, because if you had an array that had less than 5 elements, you wouldn’t want the code to try to double the 5th element which doesn’t exist! Notice that in this code, the array is a private instance variable of the class ArrayWorker. The following code doubles the first five elements in an array. You can loop through just some of the elements of an array using a for loop. You don’t have to loop through all of the elements of an array. You must start at the length of the array minus one. You can not start the index at the length of the array.The method will only return -1 if no value in the array is less than the passed value.You can also follow it in the visualizer by clicking on the Show Code Lens button. What do you think the following code will print out? First trace through it on paper keeping track of the array and the index variable.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |