posted Nov 10, 2011, 6:05 AM by Neil Mathew
[
updated Nov 10, 2011, 6:09 AM
]
Compare using a program which finds the reverse of a number:
Borland |
gcc++ |
#include <iostream.h>
void main()
{
int rev=0,digit;
int num,n;
cout<<"\n Enter the Number:";
cin>>num;
n=num;
do
{
digit=n%10;
rev=rev*10 + digit;
n=n/10;
}
while(n>0);
cout<<"\n Reverse: "<<rev;
} |
#include <iostream>
using namespace std;
int main() //Must be int
{
int rev=0,digit;
int num,n;
cout<<"\n Enter the Number:";
cin>>num;
n=num;
do
{
digit=n%10;
rev=rev*10 + digit;
n=n/10;
}
while(n>0);
cout<<"\n Reverse: "<<rev;
return 2;
}
|
|
|