PHP Assignment
PHP ASSIGNMENT -1
1. Create two integer variables (a and b) after that assign value for them. Then swap
value of a and b and print it to screen.
Hint: Using a c variable to transfer value temporary.
2. Write an application permit user input three numbers as math, physics, and chemistry.
Output average and rank according to the following:
AVG Rank
>=8.0 A
>=6.5 B
>=5.0 C
<5.0 D
Hint: Declare average and rank variable and calculate value for them.
3. Write an application accept 2 number a and b then output x is root of ax + b =0
equation.
4. Write an application to accept 03 number a, b and c the output root of ax2 + bx + c =0
equation.
5. Write a program to calculate and display sum of first 50 integer numbers to the
screen.
6. Write a program to print to screen first 20 numbers of Fibonacci numbers.
7. Create an application to manage student’s information as below:
- Create variables to save a student’s information like: studentCode, studentName,
studentAge, studentSex and set value for them.
- Print student’s information to screen.
- Edit program to permit user inputs data from keyboard.
- Edit program to permit user inputs a list of student from keyboard until “esc” key
pressed.
1
iViettech Education
Professional Programmer Training Center
8. Write a program to accepts a number n from 1 to 12 and then
print number of days in month n of the current year. If user enter
a number out of range an error message will display.
Hint: Use switch case statement
9. Write program to accepts two integer numbers (a and b), then
calculate and display their greatest common divisor.
Hint: define function int greatestCommonDivisor(int a, int b)
Example: greatestCommonDivisor (18, 12) = 6;
(Ước số chung lớn nhất – Có thể xem thuật toán trên mạng)
10. Write a program to accept an integer number and print the triangle
as below:
Example:
N=3
*
**
***
N=4
*
**
***
****
11. Write a program to accept an integer number and print the triangle
as below:
Example:
N=3
*
**
***
N=4
2
92-Quang Trung –Da Namg. Tel: 05113.888 279
PHP Assignment
*
**
***
****
The End
3
iViettech Education