QUESTION 7
Which of the following declarations correctly declares a two dimensional array of floats named prices that has 10
rows and 5 columns?
1. const int NUMROWS = 10;
const int NUMCOLS = 5;
float prices[NUMROWS + NUMCOLS];
2. const int NUMROWS = 10;
const int NUMCOLS = 5;
float prices[NUMROWS,NUMCOLS];
3. const int NUMROWS = 10;
const int NUMCOLS = 5;
float prices[NUMCOLS][NUMROWS];
4. const int NUMROWS = 10;
const int NUMCOLS = 5;
float prices[NUMROWS][NUMCOLS];
QUESTION 5
Consider the following declaration:
char codes[] = {'s', 'a', 'm', 'p', 'l', 'e'};
Which of the following array declarations is equivalent to the above declaration?
1. char codes[] = "sample";
2. char codes[5] = {'s', 'a', 'm', 'p', 'l', 'e'};
3. char codes[6] = {'s', 'a', 'm', 'p', 'l', 'e'};
4. char codes[7] = {'s', 'a', 'm', 'p', 'l', 'e'};
QUESTION 6
Which of the following function header lines is valid for a function called findMax that finds and returns the maximum
value stored in an array of integers that is passed in as a parameter?
1. int findMax(int [])
2. int findMax(int)
3. int findMax(int values[])
4. int findMax([])
QUESTION 3
Considering the following declarations:
const int NUMELS 10;
int values[NUMELS];
Which of the following C++ statements correctly outputs the seventh element of the array?
1. cout << values << 7;
2. cout << values[6];
3. cout << values[7];
4. cout << values[8];
QUESTION 4
Consider the following declarations:
const int ARRAYSIZE = 7;
float length[ARRAYSIZE] = {7.8, 6.4, 4.9, 11.2};
What is the value of length[1] and length[4]?
1. 7.8 and 11.2, respectively
2. 6.4 and 11.2, respectively
3. 7.8 and 0, respectively
4. 6.4 and 0, respectively
QUESTION 1
Consider the following declarations:
const int NUMELS 10;
int values[NUMELS];
Which of the following array accesses is valid?
1. values[-1]
2. values[10]
3. values[0]
4. values[11]
QUESTION 2
Consider the following code segment that finds the maximum value store in an array named grade of size NUMELS.
What is the missing line of code indicated by the blank line?
___________
for (i = 1; i < NUMELS; i++)
if (grade[i] > maximum)
maximum = grade[i];
1. maximum = grade[1];
2. maximum = grade[0];
3. maximum = 100;
4. maximum = grade[NUMELS];
Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.
Write a python program that reads an integer representing a month of the year, and then print the name of the month. Your program must include validation and error handling code. Thus if the user enters a value outside the range of 1-12 or characters that cannot be converted to an integer, your code must print the appropriate message and continue without crashing.
Hint: you may not use any 'if' statements
For the given IP address, determine the subnet, usable range of addresses, and Broadcast Address for Given Host 192.168.10.1;
a) English Class
For the host IP address, identify the prefix
192.168.10.1/
Identify the LSB (least significant bit)
Identify the Subnet ID to which the host belongs
Identify the broadcast address
Identify the usable range of host IP addresses
Write a program having a Class Mile with data member dis_mile. Another Class Kilometer with data member dis_kilo. Both classes stores distances. In main function create objects these two classes with parameterized constructors. Write down conversion function for converting Kilometer object to Mile class object
Active Café is a newly launch restaurant in Telupid Town. The owner wants to hire a
programmer to develop an online ordering system. The codes, menus and prices are
shown in the table below.
CODE MEAL NAME PRICE (RM)
1 Chicken Fillet 15.00
2 Roasted Beef 20.00
3 Rib eye Fillet 30.00
CODE BEVERAGE NAME PRICE (RM)
S Syrup 1.50
L Lychee 2.80
C Coconut 3.50
Based on the requirement these are what the owner wanted the system to do.
i. The customer order the meal and beverage based on the code
ii. The system will ask the quantity for each order
iii. The system displays the quantity and the total price of the meal
iv. The system displays the quantity and the total price of the beverage
v. The system displays the total price that the user needs to pay
vi. The system will repeat the process i to v until user put ‘N’ to stop the program
Mr. Pratheek wants to buy 10 items from the shop. He want to store the price of all the items. Mr. Pratheek want to list all the items which are less than a particular price. Help Mr. Pratheek to store the price of all ten items and list all the items less than a particular price
Requirements: 1: Read the price.
2: Compare the price with all price in Mr. Pratheek items
3: Display the item number whose value is less than the price.