hey,, i'm joyce, newbie.. I am very stuck in this problem,, had been on it in days. I've tried many prgrams but none seemed to work properly.
the objective is to use a function that displays a reversed version of a long integer. e.g. 12345 then display 54321.

Out of all the programs i did, i think this is the 'best' of the worst...

#include <stdio.h>
#include <conio.h>
int reverse(int num)
{
long sum=0;
int rem;
while (num=0)
{
rem=num%10;
sum=sum*10+rem;
num=num/10;
return (sum);
}
main()
{
int num, sum;
printf ("enter a no. to be reversed:");
scanf ("%d", &num);
reverse(int num);
printf ("%d", sum);
getche();
}

im sorry if i doubled stuff because i am both new to functions and forums,,, please,, i need help. IF I DON'T GET HELP, I'M GONNA FAIL COMPUTER SCIENCE...............

>>hey,, i'm joyce, newbie

Welcome to DeniWeb. Please go to the CoffeeHouse and tell us about yourself.

As for your problem if it were me I would convert the integer to a character string then just print the string backwards. You can use sprintf() to make the conversion.

> while (num=0)
Use == for comparison, = is for assignment
Though you probably want !=

> return (sum);
Think - would this be better inside or outside of the loop.

> reverse(int num);
This just prototypes the function again.
Try say sum = reverse( num );

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.