TEST 1(PHP)
From the Beginning Concept Upto Looping
Answer any one of each Assignment
save the file name as the content of assignment .
Assignment 1: Basic
PHP Syntax and Output
- Write a PHP script that outputs
"Hello, World!".
- Write a PHP script to print your name and
today's date.
- Create a PHP script that stores your first
name, last name, and age in variables and then prints them using a single echo
statement.
Assignment 2:
Variables and Data Types
- Create a PHP script that demonstrates the
following data types: String, Integer, Float, Boolean, and Array. Store
appropriate values in variables and display them.
- Write a PHP script that concatenates two
strings (first name and last name) and prints the full name.
- Create a script that performs arithmetic
operations (addition, subtraction, multiplication, and division) using two
integer variables and displays the result.
Assignment 3:
Control Structures (if-else)
- Write a PHP script that checks if a given
number is positive, negative, or zero using an if-else structure.
- Create a script that checks if a person is
eligible to vote. If the person’s age is 18 or above, print "Eligible
to vote," otherwise print "Not eligible to vote."
- Write a script that checks whether a
number is odd or even and prints the result.
Assignment 4:
Switch Statement
- Create a PHP script that takes a variable
representing the day of the week (1-7), and using a switch statement,
prints the corresponding day (e.g., 1 = Monday, 2 = Tuesday, etc.).
- Write a PHP script to check whether a
given grade (A, B, C, D, F) is valid or not using a switch statement, and
print a corresponding message.
Assignment 5: Loops
- Write a PHP script that prints the numbers
from 1 to 10 using:
- for loop
- while loop
- do-while loop
- Create a script that prints the
multiplication table of a number (for example, 5) using a for loop.
- Write a script that calculates the sum of
numbers from 1 to 100 using a while loop.
Assignment 6:
Nested Loops
- Write a PHP script to display the following pattern using nested for loops
- Create a script that prints a
multiplication table from 1 to 5 using nested loops.
Assignment 7:
Combining Conditionals and Loops
- Write a PHP script that prints all prime
numbers between 1 and 50 using a for loop and if-else statements.
- Create a script that calculates the
factorial of a given number using a for loop.
- Write a script that counts how many
numbers between 1 and 100 are divisible by both 3 and 5.
*******************************