Click here to Skip to main content
15,390,740 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
#include <iostream>
#include <iomanip>
using namespace std;
//global speed variable
float speed=80.0;
//Function to search index of destination
//by name
int SearchDestination(char Destination[5][15])
char Dst[15];
cout<<"\nEnter Destination name:";
int i;
//Loop will break and function will return index
//if search is successful
if (strcmp(Destination[i],Dst) == 0)
return (i+1);
//if search is unsuccessful it will return -1
return -1;
//Function to display details of destination
void DisplayDetails(char Destination[5][15],float Details[5][2],int index)
float time;
cout << setw(25) << left <<"Destination";
cout<<setw(5)<<" ";
cout="" <<="" setw(25)="" left="" <<"distance="" (km)";
cout<<setw(5)<<"="" <<"fare(rm)";
cout="" <<destination[index];
cout<<setw(5)<<"="" <<details[index][0];
cout<<setw(5)<<"="" <<details[index][1];
="" time="" will="" be="" calculated="" in="" mins
cout<<"\nYou" reach="" your="" destination="" "<<time<<"="" minutes.";
int="" main()
char="" destination[5][15]="{"Setiawangsa","Bangsar","Masjid" jamek","subang="" jaya","kelana="" jaya"};
float="" details[5][2]="{{40,3.50},
int" index;
char="" ch="y" ;
="" it="" run="" and="" ask="" for="" input="" till="" user="" press="" y="" or="" y
cout<<"\nenter="" the="" destination:";
cout<<"\nDo you want to continue? ";
cout<<"\nThank you";
return 0;

What I have tried:

have tried to convert it...but it say me
Updated 16-Jun-21 19:20pm
Richard MacCutchan 17-Jun-21 3:46am
Apart from the use of cin and cout, that is pretty much straight C already.

have tried to convert it...but it say me
Then try harder. You may also post your code (and the exact error message) here and ask for specific help.
After all, it is not a difficult task: you have just to convert the C++ I/O to the corresponding C. See, for instance : A Little C Primer/C Console IO - Wikibooks, open books for an open world[^].
Patrice T 19-Jun-21 16:08pm
CPallini 21-Jun-21 1:58am
Thank you.
This is not a code conversion service: we are not here to translate code for you.
Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different frameworks, and what makes something work in one language does not always "translate" directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can’t be upgraded nicely, and that will cause you immense headaches if the original is changed. And it’ll be a nightmare to debug if it doesn’t work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.

And frankly, that's poor student grade code to start with. It's not worth converting or even using as a specification ... the commenting alone is useless, the indentation shows the author doesn't care a damn, there isn't anything quality in there.

Put it back wherever you found it, and write your own homework code - you'll learn a lot more.

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