Thread: having trouble with reverse of a number program code

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    13

    having trouble with reverse of a number program code

    program to print a reverse of a number
    Code:
    #include<stdio.h>
    main()
    {
    int m,n,a,rev=0;;
    printf("enter a no");
    scanf("%d",m);
    
    while(m!=0)
    {
    rev=rev*10;
    rev=rev+(m%10);
    m=m/10;
    }
    printf("%d",rev);
    }
    its not working...please tell me where it went wrong..........

  2. #2
    Registered User
    Join Date
    Aug 2009
    Posts
    15
    the scanf statement should read scanf("%d", &m) ... also you have an extra semi-colon in the variables declaration.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    13
    Thanks dude..............

  4. #4
    Registered User
    Join Date
    Aug 2009
    Posts
    15
    you're welcome

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 12:37 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. i'm having trouble to program this!! SOS reply asap
    By Hanz in forum C# Programming
    Replies: 8
    Last Post: 09-07-2005, 06:55 AM
  4. Display Reverse Number, no strings or arrays
    By John Smith in forum C Programming
    Replies: 7
    Last Post: 12-08-2004, 05:29 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM