IT421_Midterm

  1. Declare variables cName, thisIsAName, q45D and number to be of type int.

 

  1. Display a message asking the user to enter an integer.

 

  1. Print the message "This is a program" on one line in the command window.

 

  1. Print the message "This is a program" on two lines in the command window where the first line ends with a. Use only one statement.

 

  1. State that a program will calculate the product of three integers.

 

  1. Declare the variables x, y, z and result to be of type int.

 

  1. Declare the variables xVal, yVal and zVal to be of type String.

 

  1. Prompt the user to enter the first value, read the value from the user and store it in the variable x.

 

  1. Prompt the user to enter the second value, read the value from the user and store it in the variable y.

 

  1. Prompt the user to enter the third value, read the value from the user and store it in the variable z.

 

  1. Assign x to variable xVal.

 

  1. Assign y to variable yVal.

 

  1. Assign z to variable zVal.

 

  1. Assign zero to variable result.

 

  1. Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.

 

  1. Display a dialog "The product is " followed by the value of the variable result.

 

  1. Concatenate greeting and your-name in a one line.

 

  1. Count the length of variable x where in x is an input from the user.

 

  1. Display hello word

 

  1. Count and display the length of “ simple greeting.”

 

I. Synthesis.Write php statements to accomplish each of the following: (3 pts each; 60 pts)

 

 

 

II. Write the output of the following code fragment. 20 pts

1.

<?php

  $person = 'George';

  echo '\tHello\n$person!!';

?>

 

2.

<?php

 echo 'Hello World!';

?>

 

 

 

3.

<?php

 $Greeting = 'Hello World!';

?>

<?php

 echo $Greeting;

?>

 

 

4.

<?php

             

   $greeting = $_GET['greet'];

?>

 

<?php

   echo "$greeting World!";

?>

 

 

5.

<?php

 $person = "George";

 echo "\tHello\n$person!!";

?>

 

 

 

III. Explain the following. (10 pts each:20 pts)

  1. There's two commands to start writing PHP code. <? and <?php - Which one is preferred, and why?
  2. Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/atomicoz/test.php on line 5

    Here's the code that produced the error
for ($i=0; $i<5; ++$i)


{

        echo $i

}


    


 

Post a Comment

0 Comments