this is my first thread
i need a function in C+ that return 1000000*1000000 integer given by the user in reverse but without using arrays,lists,pointers,.....
only i can use 2 or 3 variables
thanx 4 help

2
Contributors
6
Replies
7
Views
10 Years
Discussion Span
Last Post by cmoodc

Huh? 1000000*1000000 is a number that is much larger than an integer can hold. Otherwise your question doesn' make much sense to me.

sorry bro but not that what i mean!
i mean the number of the number that user will input
thanx

maybe an example will help explain what you mean. If I enter 15 what is the expected output?

maybe an example will help explain what you mean. If I enter 15 what is the expected output?

51
but i think that i've solved it

this code works
int a,b=0;
cout<<"enter the no\n";
cin>>a;
while(a>0)
{
b*=10;
b+=n%10;
a/=10;
}
cout<<"\n\n reversed no"<<b;
is it right or i need to use long instead of int
again thanx

did you try to compile that? Where did you declar n do you mean a?

>>or i need to use long instead of int
Depends on your compiler and how big a nuumber you enter. you can also use a long long which is 64-bit integer that many current compilers support. But for the purpose of your assignment I suppose an int is sufficient unless your instructor stated otherwise.

Also original numbers that end in 0, wuch as 10, 20, 100, 150, etc., may not produce desired results because integers ignore leading 0s. You may have to format the output a little better.

did you try to compile that? Where did you declar n do you mean a?

>>or i need to use long instead of int
Depends on your compiler and how big a nuumber you enter. you can also use a long long which is 64-bit integer that many current compilers support. But for the purpose of your assignment I suppose an int is sufficient unless your instructor stated otherwise.

Also original numbers that end in 0, wuch as 10, 20, 100, 150, etc., may not produce desired results because integers ignore leading 0s. You may have to format the output a little better.

everything is ok
thanx alot for helping

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.