Assignment 2 : Control Structures and Loops

 

Assignment 2 : Control Structures and Loops

1. Write a PHP Script to display a maximum of two numbers.

Practice Programs: 

1. Write a PHP Script to display a maximum of two numbers. 

Answer : 




2. Write a PHP Script to check whether a number is positive or negative. 

Answer : 



3. Write a PHP Script to display a Multiplication table of a number 

Answer : 



SET A: 

1. Write a PHP Script to check whether a year is a leap or not. 

Answer : 



2. Write a PHP Script which will perform the Addition, Subtraction, Multiplication, and Division of two numbers as per the choice. (Use Switch Case) 

Answer : 



3. Write a PHP Script to display the grade of the student according to percentage. Use the following conditions: Percentage <40 => Grade=”Fail” Percentage >= 40 and Percentage <=50 => Grade= “Pass Class” Percentage >=50 and Percentage <=60 => Grade= “Higher Second Class” Percentage >60 and Percentage <=70 => Grade= “First Class” Percentage >70 => Grade= “First Class with Distinction” 

Answer : 



SET B: 

1. Write a PHP Script to display prime numbers between 1 to 50. 6 

Answer : 



2. Write a PHP Script to display a perfect numbers between 1 to100. 

Answer : 



3. Write a PHP Script to display the reverse of a number. E.g. 607 =>706 

Answer : 



4. Write a PHP Script to display Armstrong numbers between 1 to 500. 

Answer : 


SET C: 

1. Write a PHP script to display a number in words (Use Switch case) e.g. 345–three four five

Answer : 



 2. Write a PHP script to change the background color of the browser using a switch statement according to the day of the week. 

Answer : 



3. Write a PHP script to count the total number of even and odd numbers between 1 to 1000. 

Answer : 



Assignment 2 : Control Structures and Loops Assignment 2 : Control Structures and Loops Reviewed by technical_saurabh on March 16, 2021 Rating: 5

No comments:

Powered by Blogger.