This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

609 points
Aae916adfab498ead53cebbcddfe7e64?s=140&d=retro
Submitted by
Steven Fallon
over 3 years ago

Why won't my code work?? It keeps telling me i have an error!

and it keeps telling me "Oops, try again. Your first call to round() should print an integer."

Heres the code:
<?php
// Try rounding a floating point number to an integer
// and print it to the screen
$round = round(M_PI);
print $round;
?>

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$rounddecimal = round(MPI,3);
print $round_decimal;
?>


2 votes

Best answer

permalink

Nevermind.. I looked at another answer on the forum and it was right... everything i tried wasnt working


<?php
// Try rounding a floating point number to an integer
// and print it to the screen
$test = round(3.4);
echo $test;
?>


<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$test = round(3.4312,3);
echo $test;
?>

609 points
Aae916adfab498ead53cebbcddfe7e64?s=140&d=retro
Submitted by
Steven Fallon
over 3 years ago

1 Comment

08e94eb1c8f836114e8fce03d7b73996?s=140&d=retro Ng Jia Juin over 3 years ago

Oh, I got it! Thanks!


2 votes

permalink

<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$rounddecimal = round(MPI,3);
print $round_decimal;
?>
this is your code.

this if my correct code.
$rounddecimal = round(M_PI,3);
print $rounddecimal;

293 points
50fab128a31433eb5e002dd7_260247807
Submitted by
cvmax
over 3 years ago


0 votes

permalink

Hello What I got may help you out:

<?php
// Try rounding a floating point number to an integer
// and print it to the screen
$test = round(3.4);
echo $test;
?>


<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$test = round(3.4312,3);
echo $test;
?>

781 points
540dec52282ae3fd46000466_99345759
Submitted by
Victor Rodriguez
about 3 years ago


0 votes

permalink

copy paste this if u have a problem


<?php
// Try rounding a floating point number to an integer
// and print it to the screen
$round = round(MPI);
print $round;
?>


<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$round
decimal = round(MPI, 3);
print $round
decimal;
?>


.................................................

369 points
Fcee40eef8f2195b02c722ea14c80cf5?s=140&d=retro
Submitted by
thefracture
almost 3 years ago

1 Comment

Fcee40eef8f2195b02c722ea14c80cf5?s=140&d=retro thefracture almost 3 years ago

add underscore between M and PI LIKEKE THIS M_PI