Hi I have to write a while php script that prints odd numbers between 1 and 49 then convert it into a for statement.
<?php // Script 6.2 - Odd Numbers
// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Print out 31 odd numbers.
for($i = 0;$i < 50;++$i) {
if($i % 2) {
echo "$i is odd!<br />\n";
}
?>
Can't figure out whats wrong-help!
Moderator: General Moderators
-
canadian_angel
- Forum Commoner
- Posts: 31
- Joined: Fri Jun 11, 2010 3:13 pm
Can't figure out whats wrong-help!
Last edited by canadian_angel on Mon Jun 14, 2010 9:02 pm, edited 4 times in total.
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: Don't know where to begin-help!
You can't expect us to do your school assignments for you.
You could start by looking at while loops. You want php to run a loop while the value of the investment is less than $1,000,000. In each iteration of the loop, you want php to increase the value of the investment by 15%; and you want to increment a counter which counts the number of times the loop runs.
I think you can figure it yourself from there.
You could start by looking at while loops. You want php to run a loop while the value of the investment is less than $1,000,000. In each iteration of the loop, you want php to increase the value of the investment by 15%; and you want to increment a counter which counts the number of times the loop runs.
I think you can figure it yourself from there.
-
canadian_angel
- Forum Commoner
- Posts: 31
- Joined: Fri Jun 11, 2010 3:13 pm
Re: Don't know where to begin-help!
Wasn't expecting it done for me - just a little help is all! A hint- A clue anything! A place to start that's all!
Thanks!
Thanks!
-
internet-solution
- Forum Contributor
- Posts: 220
- Joined: Thu May 27, 2010 6:27 am
- Location: UK
Re: Don't know where to begin-help!
cpetercarter has already given you the clue required.
-
canadian_angel
- Forum Commoner
- Posts: 31
- Joined: Fri Jun 11, 2010 3:13 pm