Click here to Skip to main content
15,886,077 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: (untagged)
a program using functions to convert a number entered by the user to meters and kilometers

What I have tried:

#include <iostream>

using namespace std;
int meters(int a);
int kilometers(int a);
main()
{
int a;
cout<<"enter the numbers";
cin>>a;
cout<<"the number in meters is:"<<meters(a);
cout<<"the number in kilometers is:"<<kilometers(a);
}
int meters(int a)
int kilometers(int a)
{
int x;
x=a*100;
return(x);

int x;
x=a*1000;
return(x).
}
Posted
Updated 1-Jul-18 5:26am
Comments
Krunal Rohit 2-Jul-18 0:21am    
What's happening?

KR
Richard Deeming 3-Jul-18 10:07am    
int meters(int a)
int kilometers(int a)
{
    int x;
    x=a*100;
    return(x);
    
    int x;
    x=a*1000;
    return(x).
}

Lots of syntax errors to fix there. Go back to your course notes and review how functions are defined.

Then you'll need to fix the logic errors. There's no unit where multiplying by 100 will give metres and multiplying by 1000 will give KM, or vice-versa.
Member 13894110 3-Jul-18 12:15pm    
thanks for helping.
I now see where my mistake was

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900