On 10/25/10 Mon  Oct 25, 2010  9:21 AM, "saran" <simssa...@gmail.com>
scribbled:

> i am new to perl. please help me with this piece of code below.
> answer wat it prints is correct but the format has to adjusted...!
> program to convert Celsius to Fahrenheit
> ******************************************************************************
> ****
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> print "Celsius to Fahrenheit Conversion\n";
> print "Enter the value of Celsius to be converted:";
> 
> my $c = <STDIN>;

chomp($c);

> my $f = ($c*1.8) + 32;
> print "$c"."C is equal to ", "$f","F","\n"
> 
> ***************************************************************************
> Output
> 
> Celsius to Fahrenheit Conversion
> Enter the value of Celsius to be converted:40
> 40
> C is equal to 104F
> *************************************************************************
> 
> why does "C is equal to 104F" prints on a new line rather than "40 C
> is equal to 104F"
> on a single line...
> please help

The scalar value returned by <STDIN> includes the newline. Use chomp to
remove it.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to