Welcome to AMIE Study - AMIE India Students Forum

AMIE Study - AMIE India Students Forum

collapse collapse

* Shoutbox

Refresh History
  • vae: hi
    May 19, 2019, 03:21:54 PM
  • raviteja2412: I need mining engineering previous years question paper can anyone help me
    May 13, 2019, 06:20:39 PM
  • vae: Good afternoon every1
    May 09, 2019, 01:14:34 PM
  • vae: IMNA : EXCELLENT TUITIONS  136, First Floor, Above Raghavendra Enterprises, Coconut Avenue, 8th Cross, Malleswaram, Bangalore 560 003, India.  Phone: +91 9844027371
    May 02, 2019, 05:13:30 PM
  • vae: hellooooooooooooooooooooo
    May 02, 2019, 12:36:53 PM
  • vae: Shantanu09 - You can get the full notes if  U follow the link : [link]
    May 01, 2019, 12:44:07 PM
  • vae: Dear Shahul, kindly follow the link : [link] where you can get all details
    May 01, 2019, 12:42:37 PM
  • shantanu09: HLW everyone, can anyone send me notes for material scienece
    April 30, 2019, 05:43:38 PM
  • shahul: Any one can guide me, to join new membership ST (Diploma stream) by online???
    April 30, 2019, 04:30:47 PM
  • shahul: Good evening
    April 30, 2019, 04:29:18 PM
  • vae: Hi
    April 29, 2019, 12:42:11 PM
  • imna: i am looking for coaching class in Bangalore. Please I need guidance
    April 28, 2019, 09:42:40 AM
  • imna: hello anyone from bangalore?
    April 28, 2019, 09:37:41 AM
  • T-1700565: Please send AN 205 and AN 210 NOTES
    April 25, 2019, 10:06:09 PM
  • vae: Good Afternoon Everyone
    April 25, 2019, 10:36:29 AM
  • vae: Happy Easter Every1
    April 21, 2019, 12:53:46 PM
  • RK Electrical: Can anyone send me the fundamentals of design and manufacturing pdf book link?
    April 16, 2019, 10:29:00 PM
  • vae: Happy Vishu...Everyone
    April 15, 2019, 11:30:44 AM
  • vae: hello
    April 14, 2019, 12:45:51 PM
  • SUJEET KUMAR MISHRA: Good afternoon sir, mujhe sec-a, material science ka  notes  chahiye sir
    April 13, 2019, 10:40:49 AM

* Search


* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Board Stats

  • stats Total Members: 48882
  • stats Total Posts: 27507
  • stats Total Topics: 6656
  • stats Total Categories: 6
  • stats Total Boards: 31
  • stats Most Online: 626

Author Topic: PROGRAM TO REVERSE A FIVE DIGIT NUMBER  (Read 5140 times)

Description:
February 22, 2009, 05:59:49 PM
  • Administrator
  • Senior Member
  • *****
  • Posts: 2173
  • Luck is for lazies, success is for who work hard
    • View Profile
    • AMIE Online Coaching
Advertisement
/* PROGRAM TO REVERSE A FIVE DIGIT NUMBER */
Code: [Select]
#include<stdio.h>
#include<conio.h>
main()
{
long int n;
int a;
int rev=0;
printf("Enter the 5 digit number to be reversedn");
scanf("%d",&n);

a=n%10;
rev=a*10000;
n/=10;     /* i.e, n=n/10 */

a=n%10;
rev+=a*1000; /* i.e, rev=rev+(a*1000) */
n/=10;     /* i.e, n=n/10 */


a=n%10;
rev+=a*100; /* i.e, rev=rev+(a*100) */
n/=10;     /* i.e, n=n/10 */

a=n%10;
rev+=a*10; /* i.e, rev=rev+(a*10) */
n/=10;     /* i.e, n=n/10 */

a=n%10;
rev+=a*1; /* i.e, rev=rev+(a*1) */
n/=10;     /* i.e, n=n/10 */

printf("The reversed number is %dn",rev);
//printf("Test");
getch();
}
 
« Last Edit: January 01, 1970, 04:00:00 AM by Guest »


Praveen
AMIE Study
April 13, 2010, 07:46:30 AM
Reply #1
  • Super Member
  • Senior Member
  • **
  • Posts: 107
    • View Profile
Hello friend
find below my program for same function in C++, please comment on it, advice me also.
specially I would like comments from  Mr. Praveen.


/* This is a program to reverse any number (digit is not limitation) reverse numbers */

    /*     n= Given number
           r= reverse output
           d=constant
           */

#include <iostream>
#include <cmath>

int main ()
{
    using namespace std;
int r=0,d,n;
cout << "Enter a value:";
cin >> n;
do
{
d=n%10;
n= n/10;
r=r*10+d;
}
while(n!=0);
{
cout << r << "n" ;
 system ("pause");
    return 0;
}
   
}
« Last Edit: January 01, 1970, 04:00:00 AM by Guest »
Thanks & Best Regards -
Irfan M Ansari  - Section B - Civil
Bhiwandi - Dist THANE // MAHARSHTRA
Email :[email protected]
IM: [email protected]
August 19, 2012, 09:10:20 PM
Reply #2
  • Super Member
  • Registered User
  • *
  • Posts: 61
    • View Profile
Quote from: "irfanmasiullah"
Hello friend
find below my program for same function in C++, please comment on it, advice me also.
specially I would like comments from  Mr. Praveen.


/* This is a program to reverse any number (digit is not limitation) reverse numbers */

    /*     n= Given number
           r= reverse output
           d=constant
           */

#include <iostream>
#include <cmath>

int main ()
{
    using namespace std;
int r=0,d,n;
cout << "Enter a value:";
cin >> n;
do
{
d=n%10;
n= n/10;
r=r*10+d;
}
while(n!=0);
{
cout << r << "n" ;
 system ("pause");
    return 0;
}
   
}

Hi Your programme is quite simple and no restriction on number of digits
« Last Edit: January 01, 1970, 04:00:00 AM by Guest »
August 20, 2012, 11:08:39 PM
Reply #3
  • Super Member
  • Registered User
  • *
  • Posts: 61
    • View Profile
Hi to all here iam presenting a Funny and simplest programme to reverse the number using "strrev" function
Programme thinks the Input number as Text string and reverses it easily ...

Code: [Select]
/*REVERSES A NUMBER UPTO 100 DIGITS*/
#include<stdio.h>
#include<conio.h>
 
main()
{
   char arr[100];
   printf("Enter a number to reversen");
   gets(arr);

   /*THIS STRREV FUNCTION IS DOING THE MAGIC*/

   strrev(arr);
   printf("Reverse of entered number is n%sn",arr);
   getch();
}


Output

[attachment=0:15qq19o1]Reverse Simple.jpg[/attachment:15qq19o1]
« Last Edit: January 01, 1970, 04:00:00 AM by Guest »
 

Related Topics

  Subject / Started by Replies Last post
0 Replies
636 Views
Last post March 18, 2009, 02:12:47 PM
by rohit.wadhwa
1 Replies
4533 Views
Last post November 28, 2011, 07:18:22 PM
by praveen
4 Replies
1693 Views
Last post January 05, 2013, 09:47:21 AM
by spganeshk
0 Replies
888 Views
Last post September 06, 2012, 09:05:23 PM
by sainathan
0 Replies
929 Views
Last post September 15, 2012, 04:48:54 PM
by jitu_12341
0 Replies
1151 Views
Last post January 13, 2013, 09:31:42 AM
by avidwan
1 Replies
1117 Views
Last post October 20, 2014, 08:57:08 AM
by RAVI MENARIA

* Search

* Subscribe to Forum

Enter your email address:

Advertisement

* Recent Posts

Solid Wood Dining Table Set Uk by arafats
[May 24, 2019, 05:35:06 PM]


Re: All About AMIE by vae
[May 09, 2019, 04:40:15 PM]


Re: All About AMIE by vae
[May 09, 2019, 04:26:26 PM]


Re: All About AMIE by vae
[May 09, 2019, 01:12:24 PM]


Re: All About AMIE by vae
[May 09, 2019, 01:03:32 PM]