"Welcome to our PHP 101 blog, where we demystify the world of web development. "

Friday, September 20, 2024

Test1(PHP : From Beginning to loop)

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

  1. Write a PHP script that outputs "Hello, World!".
  2. Write a PHP script to print your name and today's date.
  3. 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

  1. Create a PHP script that demonstrates the following data types: String, Integer, Float, Boolean, and Array. Store appropriate values in variables and display them.
  2. Write a PHP script that concatenates two strings (first name and last name) and prints the full name.
  3. 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)

  1. Write a PHP script that checks if a given number is positive, negative, or zero using an if-else structure.
  2. 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."
  3. Write a script that checks whether a number is odd or even and prints the result.

Assignment 4: Switch Statement

  1. 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.).
  2. 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

  1. Write a PHP script that prints the numbers from 1 to 10 using:
    • for loop
    • while loop
    • do-while loop
  2. Create a script that prints the multiplication table of a number (for example, 5) using a for loop.
  3. Write a script that calculates the sum of numbers from 1 to 100 using a while loop.

Assignment 6: Nested Loops

  1. Write a PHP script to display the following pattern using nested for loops
                                


  1. Create a script that prints a multiplication table from 1 to 5 using nested loops.

Assignment 7: Combining Conditionals and Loops

  1. Write a PHP script that prints all prime numbers between 1 and 50 using a for loop and if-else statements.
  2. Create a script that calculates the factorial of a given number using a for loop.
  3. Write a script that counts how many numbers between 1 and 100 are divisible by both 3 and 5.




*******************************

No comments:

Post a Comment

Pages

SoraTemplates

Best Free and Premium Blogger Templates Provider.

Buy This Template