how to generate reverse number ?

reverse number in digits ?
One solution is to read it as a string and reverse it.
You can use division and modulo operators
thanks a lot..
you can use stack to reverse string ...I think it is more faster.
can you guys help me fix the syntax & logic errors ?? please i need it asap..

//Debug6-1
// function counts down from higher number to lower number entered
// e.g., if numbers entered are 4 and 8
// output is : 8 7 6 5 4
#include<iostream>
using namespace std;
int main()
{
void countDown(int lowest,int highest);
int highest,lowest;
cout <<"I will count down from the higher number you enter to the lower one " << endl;
cout <<"Enter a number" << endl;
cin >> highest;
cout <<" Enter another number " << endl;
cin >> lowest;
if(highest<lowest);
{
lowest=highest;
highest=lowest;
}
void countDown(int high,int low );
return 0;
}
void countDown(int lowest , int highest);
{
int x;
for(x=highest; x=lowest;--x)
cout << x << "" << endl;
}
( no 2 ) can you guys help me fix the syntax & logic errors ?? please i need it asap..

//debug6-2
// user enters price
// program computes tax rate
// 5% at prices $10 and under , otherwise 7%

#include<iostream>
using namespace std;
int main()

{
double price();
double calcTax(double);


double price;
double taxRate;
askPrice();
taxRate = calcTax()
cout <<" on $ << price << ", the taxRate is " << taxRate << endl;
return 0;
}
double price askPrice()
{
double price;
cout <<"Enter price $";
cin >> price;
return price;
}
double calcTax(double price)
{
double rate;
const double CUTOFF = 10.00;
const double LOWRATE = 0.05;
const double HIGHRATE = 0.07;
if(price <= CUTOFF)
rate=LOWRATE
else rate = HIGHRATE;
}

Please use [code][/code] tags

1
2
lowest=highest;
highest=lowest;
Won't swap the values, once you assign lowest=highest you'll lose the value of highest, either use a temporary variable or call std::swap.

You are declaring countDown twice inside main but never call it.

The for in countDown is wrong

//debug6-2
// user enters price
// program computes tax rate
// 5% at prices $10 and under , otherwise 7%

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
using namespace std;
int main()

{ 
double price();
double calcTax(double);


double price;
double taxRate;
askPrice();
taxRate = calcTax()
cout <<" on $ << price << ", the taxRate is " << taxRate << endl;
return 0;
}
double price askPrice()
{
double price;
cout <<"Enter price $";
cin >> price;
return price;
}
double calcTax(double price)
{
double rate;
const double CUTOFF = 10.00;
const double LOWRATE = 0.05;
const double HIGHRATE = 0.07;
if(price <= CUTOFF)
rate=LOWRATE
else rate = HIGHRATE;
}  

Topic archived. No new replies allowed.