Please staple the assignment together. At the top of the first page print, in this order: your first name, your last name, CIS33A, and the assignment letter. Print the exercise or problem number at the beginning of each exercise and problem. Assignments are due at the beginning of class, and will be marked down if turned in later.
Authorship note: These assignments have been adapted from assignments given by Clare Nguyen, who adapted them from the work of Behrouz Forouzan.
There are 2 types of problems.
Show the result of the following expressions:
Show the result of the following expressions:
What is the value of $x and $y after the following statements?
$x = 4;
$x++;
$y += $x + 3;
Which of the following expressions evaluate to true, and which evaluate to false?
What is the value of each of the following expressions?
Which of the following expressions evaluate to true, and which evaluate to false?
The following statements set the values:
Then, which of the following expressions evaluate to true, and which evaluate to false?
Code a single statement, which uses the &&
operator,
and produces the same results as this code:
if ( $x < 10 ) { $x++; }
Code a single statement, which uses the ||
operator,
and produces the same results as this code:
unless ( $x < 10 ) { $x++; }
Write a program that reads in three numbers:
Ask the user to input a decimal number as the first number.
Ask the user to input an octal number without the leading 0 as the second number.
Ask the user to input a hexadecimal number without the leading 0X
as the third number.
Convert each number to decimal.
Print the following output, with description of each number:
Print the decimal value of the first number.
Print the octal and then the decimal value of the second number.
Print the hexadecimal and then the decimal value of the third number.
Use the following test data, in order: 1234 123 12
In this problem, do not use a loop.
Write a program that reads one string and prints it as many lines as its length with
each copy on a separate line (The \n should not he considered when calculating the
length).
For example, if the string is "world", the output should be as shown below
(the length is 5):
world world world world world
Write a program that has a long string given which contains at least three 'e'
The program finds the positions of the
first, second, and third "e" in the string and prints the results.
Test the program with the data:
$string = 'elephants eat a large quantity of food';
Write a program that has a long string given.
The program extracts the first five characters and the last five characters.
and prints the results.
Test the program with the data:
$string = 'elephants eat a large quantity of food';
Write a program that, given three strings, uses string comparisons to select and print the smallest in ASCII sort order. Do not use the sort function.
Write a program that, given an integer between 1 and 12, prints the corresponding month of the year (January, February, ...).
Write a program that, given a floating-point number,
prints the number rounded to two digits.
For example. 14.334 will be rounded to 14.33 but
14.336 will be rounded to 14.34.