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

Cs 122 Lab Questions Set 1: PRACTICE. Inside The PRACTICE Folder, Create Another Folder Named by

This document provides instructions for computer science students to organize their work for a lab assignment on their lab computers. Students are instructed to create a folder structure with their registration number to store their work. Any student working on the lab computers for this course should place their work in the CS 122 Practice folder. The document then lists 10 questions for programming assignments involving arrays.

Uploaded by

ngissa
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)
112 views2 pages

Cs 122 Lab Questions Set 1: PRACTICE. Inside The PRACTICE Folder, Create Another Folder Named by

This document provides instructions for computer science students to organize their work for a lab assignment on their lab computers. Students are instructed to create a folder structure with their registration number to store their work. Any student working on the lab computers for this course should place their work in the CS 122 Practice folder. The document then lists 10 questions for programming assignments involving arrays.

Uploaded by

ngissa
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

CS 122 LAB QUESTIONS SET 1

On the Lab computer, create a folder on the desktop name it CS 122


PRACTICE. Inside the PRACTICE folder, create another folder named by
your registration number (eg. T.UDOM.2014.00001). Again, create a folder
within the one named by your registration number and give it name LAB
SET 1. Store all of your work in this lab questions in LAB SET 1. Next time,
create a new folder and name it LAB SET 2 and so on.
ANY STUDENT WHO WORKS ON THE LAB COMPUTERS FOR THIS COURSE
SHOULD PLACE HIS WORK UNDER THE CS 122 PRACTICE FOLDER. YOU MAY
COPY YOUR FOLDER.
1. Write a program that declares an array of three integers. Assign values to each array position
and use a loop to print out its contents.
2. Create a program that declares an array numbers of type int with size 5. Use a loop to print
out the value at each index (HINT: Do not assign anything into the array. Just declare and
print. Compare your results to someone elses working on nearby machine).
3. Create a program that declares an array of 5 int values and initialize the first position with
any int value using an initializer list.
4. By careful examining the output of program 2 and that of program 3, what can you say about
the initial values of an array when it has not been initialized at all and when a sample
5.

initial value is given?


a. Write down a program that declares an array of ten integers
b. Using a for loop, assign values to the array in 5(a) in such a way that each position

gets a value equal to 9 times its position.


c. Use a while loop to print out the contents of the array on a single line
6. Construct a program that declares an array of five strings. Assign your best friends names
into the five slots of the array. Use a for loop to print out the five names that has been stored
in the array.
7. Write a program that declares three arrays of size four. Name the first as float array
leftOperands, the second as char array operators and the third as float array rightOperands.
Assign random values to the leftOperands and rightOperands arrays. Store the four
algebraic operators in the operators array. Using a single for loop on the array operands and
a switch statement to examine the operator at each index, perform the operation between the

Page 1 of 2

values in the leftOperands and rightOperands stored at the same index location as the
operator.
8. Using a global constant or variable, declare an integer array of not more than 5 elements and
assign values to it in the main function. Use a separate function to display the values in the
array.
9. Write a program that consists of three parts: main(), enterValues() and printValues(). In
main(), declare a float array called myNumbers. Call function enterValues() to prompt the
user to enter values into the array. Call function printValues() to output the values in the
array. Use a global variable NUMBERS to hold the size of your array.
10. By examining the program you have written in 8 and the output it gives, do you think arrays
are passed to functions by value or by reference?

Page 2 of 2

You might also like