Results 1 to 2 of 2

Thread: program to print the reverse of a 4 digit number

  1. #1

    program to print the reverse of a 4 digit number

    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    
    int rev(int);
    int n;
    
    main()
    {
    	printf("Enter the no.:");
    	scanf("%d",&n);
    	printf("/n The reversed number is %d",rev(n));
    	getch();
    }
    
    
    int rev(int n)
    {
            int temp=0;
    	for(int i=1;i<4;i++)
    	{
    		temp+= ((n%10) * pow(10,4-i));
    		n=n/10;
    	}
    	return(temp);
    }
    Last edited by Harsh; 02-26-2011 at 03:49 PM.
    techforum4u.com Member!!

  2. #2

    Re: program to print the reverse of a 4 digit number

    tHis way to use code blocks
    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    
    int rev(int);
    int n;
    
    main()
    {
    printf("Enter the no.:");
    scanf("%d",&n);
    printf("/n The reversed number is %d",rev(n));
    getch();
    }
    
    
    int rev(int n)
    {
    int temp=0;
    for(int i=1;i<4;i++)
    {
    temp+= ((n%10) * pow(10,4-i));
    n=n/10;
    }
    return(temp);
    }
    techforum4u.com Member!!

Similar Threads

  1. Replies: 0
    Last Post: 11-05-2011, 04:58 PM
  2. Replies: 0
    Last Post: 11-04-2011, 07:55 AM
  3. Replies: 5
    Last Post: 03-04-2011, 12:35 PM
  4. Replies: 0
    Last Post: 02-25-2011, 03:41 AM
  5. Replies: 0
    Last Post: 02-13-2011, 08:09 PM

Members who have read this thread : 1

You do not have permission to view the list of names.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Disclaimer: Users of techforum4u.com are responsible for ensuring that any material they post (article, blog posts, images or other mulitimedia content) does not violate or infringe upon the copyright, patent, trademark, or any personal or proprietary rights of any third party, and is posted with the permission of the owner of such rights.Anyone who violates these rules may have their access privileges removed without warning.