reverse number..i need 3 outputs

i need reverse integer 3 outputs


sample input is
24 1
4358 754
305 794

sample output is
34
1998
1

This problem is need to reverse the integer and add them up and reverse the added number again..but,i can;t get three output,i just got 1 reverse output..

#include <iostream>
using namespace std;


int input1();
int input2();
int input3();
int input4();
int input5();
int input6();
int reverse(int input_1);
int calculate(int,int);
int calculate2(int,int);
int calculate3(int,int);
void print(int,int,int);

int main()
{
int num1,num2,num3,num4,num5,num6,process1,process2,process3,process4,process5,process6,display,display2,display3;

num1=input1();
num2=input2();
process1=reverse(num1);
process2=reverse(num2);

num3=input3();
num4=input4();
process3=reverse(num3);
process4=reverse(num4);

num5=input5();
num6=input6();
process5=reverse(num5);
process6=reverse(num6);

display=calculate(process1,process2);
display2=calculate2(process3,process4);
display3=calculate3(process5,process6);

print(display,display2,display3);
}

int input1()
{
int num1;

cin >> num1;

return num1;
}

int input2()
{
int num2;

cin >> num2;

return num2;
}

int input3()
{
int num3;

cin >> num3;

return num3;
}

int input4()
{
int num4;

cin >> num4;

return num4;
}int input5()
{
int num5;

cin >> num5;

return num5;
}

int input6()
{
int num6;

cin >> num6;

return num6;
}
int reverse(int input_1)
{

int value = 0;

while (input_1)
{
value=value*10;
value= value+input_1%10;
input_1=input_1/10;
}


return value;
}


int calculate(int num1,int num2)
{
int ans1;

ans1=num1+num2;

return ans1;
}
int calculate2(int num3,int num4)
{
int ans2;
ans2=num3+num4;
return ans2;
}
int calculate3(int num5,int num6)
{int ans3;
ans3=num5+num6;
return ans3;
}
void print(int input_2,int input_3,int input_4)
{

int value = 0;

while (input_2)
{
value=value*10;
value= value+input_2%10;
input_2=input_2/10;
}
cout<<value<<"\n";

while (input_3)
{
value=value*10;
value= value+input_2%10;
input_2=input_2/10;
}
cout<<value<<"\n";
while (input_4)
{
value=value*10;
value= value+input_2%10;
input_2=input_2/10;
}

cout << value<< "\n";
}
Last edited on
whoah.. wow.. um.. i'm speachless..

Ok, first off, please put code inside of [code][/code] tags. This makes it more readable. It highlights and perserves indentation and spacing.

Second.. why all the input functions? You don't need a seperate function for every input. You need one input function, and call that to store the return value into each of the num variables.

Same goes for the reverse and calculate. You're already passing the numbers to the functions. You can use the same function over and over again with different numbers and get different results.

You've seem to have missed the whole point of re-usability.

Correct that and then we'll get into what's giving you the error.
Topic archived. No new replies allowed.