Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-15-2003, 08:37 AM   #1
LQ Newbie
Registered: Sep 2003
Location: hyderabad
Posts: 12

Rep: Reputation: 1
reversing a number

how to take a number from input
and reverse it

int sum=0,t=1;
char ch;

the abvove code works with a '\n' (or) '.'
can i write a funtion tom reverse it with out using . or \n;

waiting for u r reply.......
Old 11-15-2003, 09:25 AM   #2
Registered: Feb 2003
Location: Atlanta, GA
Distribution: RHAS 2.1, RHEL3, RHEL4, SLES 8.3, SLES 9, SLES9_64, SuSE 9.3 Pro, Ubuntu, Gentoo
Posts: 335

Rep: Reputation: 32
Why not do this in Perl?

#!/usr/bin/perl -w
use strict;
my $digit;
print "Enter number:";
$digit = <STDIN>;
chomp $digit;
print "Number = $digit\n";
$digit = (reverse $digit);
print "Reverse Number = $digit\n";

If want to cut this script down even more:

#!/usr/bin/perl -w
print "Enter number:";
$digit = <STDIN>;
chomp $digit;
$digit = (reverse $digit);
print "Reverse Number = $digit\n";


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
reversing rrdtool graphs whysyn Linux - Software 0 06-05-2005 04:31 PM
reversing connectors on SCSI cable randyding Linux - Hardware 1 04-08-2005 05:26 PM
reversing program greenthing Programming 3 02-27-2005 08:08 PM
java, reversing digit Lifesaver Programming 5 03-03-2004 04:09 PM
reversing videocard lackluster Linux - Hardware 1 11-16-2002 02:58 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:37 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration