Вы находитесь на странице: 1из 2

Write declaration statements for the following variables:

a. val1, val2, and val3 used to store integer numbers. (1m)


b. amps1, amps2, amps3, and amps4 used to store double-precision numbers. (1m)
c. codeA, codeB, codeC, codeD, and codeE used to store strings. (1m)
Write relational expressions to express the following conditions (using variable
names of your choosing):
a. A speed is 22 kmph. (1m)
b. The current month is 06 (June). (1m)
c. The letter input is M. (1m)
Given the declaration below, code the statement to assign the element in the first
row and second column a value of 99.  (2m)
     int scores[3][2] = {0};
Write the statement to determine the length of the name string defined below and
place the value into the number variable.  (2m)
     int number = 0;
     string name = "Hello";
Given the array declaration below and user prompt, write the statement to place the
value entered by the user into the first array element using the extraction operator.
(2m)
      int numbers[5] = {0};
      cout << "Enter the first number: ";
Given the declarations below, write the statements to combine the person's full name
and store it into the full string variable.   (2m)
     string first = "First";
     string middle = "Middle";
     string last = "Last";
     string space = " ";
     string full = "";
Write a void function named "calcMin", that would accept three integer arguments num1,
num2 and min, first two arguments will be passed by value and the third to be passed by
reference. The function should determine the smallest number and store the result
in min variable. If the numbers are equal, then it should store zero in min variable. [5m]

Given the following, write the statement to store the characters entered by the user, up
until the newline character, in the name variable; and consume the newline character.
(2m)
     string name = "";
     cout <<"Enter your name: ";
What library needs to be included to be able to use math functions? (1m)

Declare an array called intNum to store 10 integer values. Then, use a  for loop to store first
10 even numbers, into the intNum array. The first even number is 2.  (5m)

Given the following code: (2m)


int x = 1;
int y = 2;
int z = 3;
What will the result of the condition in the if statement below be? Show your
evaluation breakdown.
     if ( (x == 2) || (y == 2) || (z == 2) )
Write appropriate statements for the following condition: (3m)
If an angle is not equal to 90 degrees, print the message "The angle is not a
right angle"; else, print the message "The angle is a right angle."
For the variables and addresses shown below, fill in the data determined by the
following statements:
a. ptDay = &m;
b. *ptDay = 2035;
c. years = *ptDay;
 
Determine the output of the following code segment. Assume necessary header files
are used. Show all necessary calculations.  (8m)
   int main()
   {
   int num = 1;
   while(num < 10)
   {
   num = num-2;
   cout<<num<<" ";
   num += 4;
   }
   return 0;
   }

Вам также может понравиться