To print reverse of five digit number





#include
#include

main()
{
int i;
long int n,n1,a,b,c;
clrscr();
printf("give five digit number ");
scanf("%ld",&n);
n1=n;
for(i=1;i<=5;i++)
{
a=n1%10;
b=n1-a;
printf("%d",a);
n1=b/10;
}
}

6 comments:

  1. Write a program that reads a list of integers from the keyboard and creates the following information: a. Finds and prints the sum and the average of the integers b. Finds and prints the largest and the smallest integers c. Prints a Boolean(true or false) if some of them are less than 20 d. Prints a Boolean(true or false) if all of them are between 10 and 90. The input data consist o a list of integers with a sentinel. The program must prompt the user to enter the integers, one by one, and enter the sentinel when the end of the list has been reached

    ReplyDelete
  2. #include


    main()
    {

    int i,no,a,b,c;

    printf("give five digit number ");
    scanf("%ld",&no);

    for(i=1;i<=5;i++)
    {
    a=no%10;
    no=no/10;
    printf("%d",a);

    }
    }

    ReplyDelete
  3. #include
    #include
    void main()
    {
    int num,rem,rev=0,a,i,sum=0;
    clrscr();
    printf("Enter the five digits number=");
    scanf("%d",&num);
    printf("Entered the five digits number=%d",num);
    for(i=1;i<=4;i++)
    {
    rem=num%10;
    rev=rev*10+rem;
    sum=sum+rem;
    num=num/10;

    }
    printf("\n Sum of reverse is=%d",sum);
    printf("\n Reverse number is=%d",rev);


    getch();
    }

    ReplyDelete
  4. can we print these five no in reverse order without using mod and division?

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. pls help me solve this:
    Write c program that ask the users to enter 3 integer numbers and then prints the entered number in reverse order.
    Ex.
    Enter 1st number: 5
    Enter 2nd number: 3
    Enter 3rd number: 19
    The number is reverse order: 19 35
    press any key to continue

    ReplyDelete