Q:

PHP program to demonstrate the use of printf() function

belongs to collection: PHP Classes & Objects Programs

0

Here, we will use the printf() function just like C programming language for formatted output.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to demonstrate the use of the printf() function is given below. The given program is compiled and executed successfully.

<?php
    //PHP program to demonstrate the 
    //use of printf() function.
    
    $A = 10;
    $B = 20;
    
    $C = $A + $B;
    printf("Sum is: %d",$C);
?>

Output:

Sum is: 30

Explanation:

In the above program, we created two local variables $A$B that are initialized with 10 and 20 respectively. Then we assigned the sum of $A and $B to the variable $C, and then printed the sum of $A and $B using printf() function on the webpage.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP Classes & Objects Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
PHP program to demonstrate the use of the local an... >>
<< PHP program to print the method name with the asso...