-
inverting integers.
How can i write a program that accepts an integer stores it in a variable1.The program then reverses the digits in the integer and stores them in another variable2,then outputs both integers?
Example:
you enter 387 the value is reversed to 783.
NOTE:The new value MUST be stored in variable2 before it is output.
-
You've gotta start posting your initial efforts with your questions!
-
my "initial efforts" resulted in nothing but syntax errors so dont have initial efforts that i can actually speak of,any ideas?
-
Show us the code, show us the syntax errors, we'll help you out. We do not do homework for you, it defeats the purpose of you being set homework.
-
> my "initial efforts" resulted in nothing but syntax errors
Well the first step at least is to finish off all the input and output
Code:
printf ( "Enter a number\n" );
scanf( "%d", &inputValue );
outputValue = inputValue;
printf( "The result is %d\n", outputValue );
Once you've done that, then you can work on replacing the outputValue = inputValue; with the actual code which does what you want.
Hint: Look up the / and % operators
-
but won't outputvalue=inputvalue only dublicate the inputvaluei.e the will give interger that you enterd?
-
Code:
int main()
{
int i,j;
printf("Enter an interger: ");
scanf("%d",i);
Ok give me a hint:
what kind of code am looking to make?
-
> but won't outputvalue=inputvalue only dublicate the inputvaluei.e the will give interger that you enterd?
Exactly, but until you can prove to yourself that you can reliably input a value and output it again unchanged, there is no way that you can progress onto the next bit. Even if you stumble on the correct answer you won't know that you have if the input is broken to start with.
Try printing the result of inputValue % 10
-
This person's posts just go to show that no matter where in the world you are, there will always be lazy people who want everything done for them without any effort on their part. :mad:
Quzah.