CSC1511
Computer Programming
Tutorial 5
//Jayllarzel
1. Write a C++ statement(s) that accomplish the following array:
a) Declare an array named myList of 20 components of type int.
int myList[20];
b) Display the value of the tenth component of the array myList.
cout<<myList[9];
c) Set the value of the fifth component of the array myList to 35.
myList[4]=35;
d) Set the value of the ninth component of the array myList to the sum of the sixth and thirteen
components of the array myList.
myList[8]=myList[5]+myList[12];
e) Set the value of the fourth component of the array myList to three times the value of the
eight components minus 30.
myList[3]=3*myList[7]-30;
f) Declare a new array named specialSymbols of type char. Initialize this array to the
following values: $, #, %, @, &, !, =
char specialSymbols[]={‘$’,‘#’,‘%’,‘@’,‘&’,‘!’,‘=’};
Computer Programming
Tutorial 5
//Jayllarzel
1. Write a C++ statement(s) that accomplish the following array:
a) Declare an array named myList of 20 components of type int.
int myList[20];
b) Display the value of the tenth component of the array myList.
cout<<myList[9];
c) Set the value of the fifth component of the array myList to 35.
myList[4]=35;
d) Set the value of the ninth component of the array myList to the sum of the sixth and thirteen
components of the array myList.
myList[8]=myList[5]+myList[12];
e) Set the value of the fourth component of the array myList to three times the value of the
eight components minus 30.
myList[3]=3*myList[7]-30;
f) Declare a new array named specialSymbols of type char. Initialize this array to the
following values: $, #, %, @, &, !, =
char specialSymbols[]={‘$’,‘#’,‘%’,‘@’,‘&’,‘!’,‘=’};