4eca117dceb264011398969700e63bda
htmlphp
lab1
v2
rasb14
2017-09-02 17:52:52
v2.3.3 (2017-06-12)

Generated 2017-09-02 20:06:46 by dbwebb lab-utility v2.3.3 (2017-06-12).


Lab 1 - htmlphp

If you need to peek at examples or just want to know more, take a look at the PHP manual.

Here you will find everything this lab will go through and much more.

1. Integers, floats and basic arithmetics

The foundation of numbers and basic arithmetic.

Exercise 1.1 (1 points)

Create two variables called numOne and numTwo and assign to them the values 261 and 348.

Sum up the variables and answer with the result.

Exercise 1.2 (1 points)

Use your two variables numOne and numTwo. Subtract numOne from numTwo and answer with the result.

Exercise 1.3 (1 points)

Divide numOne with numTwo and use the function round() to round the answer to 1 decimal.

Exercise 1.4 (1 points)

Create a variable called floatOne and give it the value 313.53. Create another variable called floatTwo and give it the value 173.94. Sum up the variables and answer with the result rounded to 2 decimals.

Exercise 1.5 (1 points)

Subtract floatOne from floatTwo, round up to 3 decimals and answer with the result.

Exercise 1.6 (1 points)

Create a variable called floatThree and give it the value 63.32. Add floatOne to floatTwo and multiply the result with floatThree, take that result and divide it by numOne.

Answer with the result rounded to 4 decimals.

Exercise 1.7 (1 points)

Create a variable modOne with a value of 907 and a variable modTwo holding the value 40.

Answer with the result of modOne modulo (%) modTwo.

2. Extra assignments

These questions are worth 3 points each. Solve them for extra points.

Exercise 2.1 (3 points)

You are going to solve the well-known ‘chessboard and rice grain problem’.

Imagine you have a standard chessboard and put one rice grain on the first square. Then you put two grains on the second square, four on the third, eight on the fourth and so on… How many rice grains are there on the last square?

Answer with the square root of the result, rounded to 2 decimals. (Make sure the answer is of the type double).

Exercise 2.2 (3 points)

Sum all numbers from 1 to 100. Answer with the result. (Make sure the answer is of the type integer)


4eca117dceb264011398969700e63bda