#!usr/bin/perl
print " This program will print all 10 decimal places.\n";
print "Enter an integer value.\n";
$value =<STDIN>;
#$value=1;
#chop($value);
$a = $value+1;
print "$a\n";
while ($value<$a) {
## if($value == 9){
## #exit;
## print "Value is now 9\n";
## }
print "value has become $value\n";
$value=$value+0.1;
## print "Value after increment is : $value\n"
}
print "EOF.\n";
~
output: 1.When I entered 3: This program will print all 10 decimal places. Enter an integer value. 3 4 value has become 3 Value after increment is : 3.1 value has become 3.1 Value after increment is : 3.2 value has become 3.2 Value after increment is : 3.3 value has become 3.3 Value after increment is : 3.4 value has become 3.4 Value after increment is : 3.5 value has become 3.5 Value after increment is : 3.6 value has become 3.6 Value after increment is : 3.7 value has become 3.7 Value after increment is : 3.8 value has become 3.8 Value after increment is : 3.9 value has become 3.9 Value after increment is : 4 EOF. 2. when I entered 10: This program will print all 10 decimal places. Enter an integer value. 10 11 value has become 10 value has become 10.1 value has become 10.2 value has become 10.3 value has become 10.4 value has become 10.5 value has become 10.6 value has become 10.7 value has become 10.8 value has become 10.9 value has become 11 EOF. There are two different outputs: When I enter number 1 to 4 (1,2,3,4) then output is what is expected but when input is greater than 4 then output is different.
In reply to While loop;s different behavior by Maahi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |