Code executes fine, but the values that are returned are not correct. For example I get a value of 00136C57DA. Does this have something to do with the formulas used?
I think you want to output the value that's returned by the diameter function? If yes, you can just call the function in the output statement. The main function doesn't know about the local variable diameter that you declared in the diameter function so you can't cout << diameter in main. Or you could declare a local variable in main function to hold the result of the diameter function.
how do i solve this, im trying to create a program that translates from english to french it is giving me this error " Error 1 error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::basic_string<_Elem,_Traits,_Ax> &,unsigned int,unsigned int,const std::allocator<_Ty> &)' : cannot convert parameter 1 from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'const std::basic_string<_Elem,_Traits,_Ax> &' " on my program where i have "translate(phrase.begin()"
this is my program:
#include<iostream>
#include<string>
#include <algorithm>
#include <cctype>
#include <map>
using namespace std;
int selection;
int main()
{
map<string, string> dict;
dict["Welcome"] = "bienvenue";
do
{
cout<<" Which language would you like to translate from: \n 1: English to French \n 2: French to English \n 3: Exit program"<<endl;
cin>>selection;
bool finished = false;
string phrase;
while (!finished)
{
cin.ignore();
if (selection == 1)
{
cout<<" Please enter the word or sentence you would like to translate: ";
getline(cin, phrase);
string translate(phrase.begin(), phrase.end(), phrase.begin(), tolower);
if (dict.count(phrase) == 0);