### how do i convert words into tones and base freq?

here's my problem

main.cpp|20|error: expected ';' before 'multiplies'|
main.cpp|20|error: missing template arguments before ')' token|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

code:

#include <iostream>
#include <string>

using namespace std;

int main()
{

string tone;
cout << "please type in Keywords: ";
getline(cin, tone);

int Hz = tone.length();

for (unsigned int i = 0; i < tone.length() multiplies )
if (tone.at(i) == ' ' ); {
Hz--;
}

cout << "Hz: " << Hz << endl;

return 0;
}

how do i mupltiply the words that i'm counting? do i have this right?
You have incorrect syntax for your for loop. What are you trying to accomplish with it?
i'm trying to figure out how to calculate words into tone and base hz: in frequencies that the musical note is a single frequencies.

see like this

for example i want to calculate expand wisdom, well it should come out to tone hz: 741 hz and also base Hz 136.10 Hz.

that's what i'm trying to accomplish.
what syntax do i use for this?
heres what i'm looking to do. i'm looking to do is multiply the 2nd cout sperately. here's the code. please help and add to it.

code:

#include <iostream>
#include <string>

using namespace std;

int main()
{

string input_hz;
cout << "please type in Keywords: ";
getline(cin, input_hz);

int Hz = input_hz.length();

for (unsigned long long k = 1; k < input_hz.length(); k = 200)
if (input_hz.at(k) == ' ' ); {
Hz--;
}

cout << "Hz: " << Hz << endl;
cout << "Hz: " << Hz << endl;

return 0;
}
You should look up the syntax of a for statement; what you are doing with it does not make sense.

 i'm trying to figure out how to calculate words into tone and base hz: in frequencies that the musical note is a single frequencies.

I don't understand what you are trying to say. What does it mean to "calculate words into tone and base Hz"? Do you have some algorithm you are trying to implement? I am not familiar with whatever domain you are working in so you'll need to give a little more detail.

 i'm looking to do is multiply the 2nd cout sperately.

What does this mean? Multiply the cout? cout is an output stream, not a number. Do you mean that you want display it multiple times? Or calculate something differently? I'm lost.
i want to add the tone of words in length and the same for multiple the Mhz. i want to limit the multiplication and adding. how do i have it automatic the subtractions and addition also with multiplication by float decimal point?

when i try to compile the new code that have below this is the error i got:
error: expression list treated as compound expression in initializer [-fpermissive]|

how do i declare the function in line 22?
do i declare variable in this part?

error in this part:
`float getline(cin, Hz, Mhz);`

 ``123456789101112131415161718192021222324252627282930313233343536373839`` `````` #include #include using namespace std; float multiplies(float Hz, float Mhz); int main() { float add(float Hz); float multiple(float Mhz); ;const char Hz = 1000; ;const char MHz = 20000; { } cout << "please type in Keywords: "; float getline(cin, Hz, MHz); { } for (float x = 1; i < Hz.length ; i++) for (float x = 1; x < MHz.length ; x++) if (Hz.at(i)); (Mhz.at(x)) == ' ' ); { } cout << "Hz: " << Hz << endl; cout << "MHz: " << Mhz << endl; return Hz+Mhz;``````

i'm new to this and i'm learning this.
Last edited on
what am i doing wrong with this program c++ code?
A lot is wrong here; perhaps you should take another look at the tutorial....
Line 7: function declared but never defined.
Lines 16 & 17: Never begin a line with a semicolon.
Lines 18-20: Why the curly brackets?
Line 22: you never named the variable.
Lines 24-26: Why the curly brackets?
Line 28: you meant
 ``123`` ``````for(int i=0;i
replace the && with || if you want it to be one or the other. And actually do something in the loop.
Line 39: Main always returns 0. And you need a curly bracket after it to close the main function
what should i put in where Line 22 and can you give me a example and do i use the string or float?
also Lines 18-20: Why the curly brackets? i want to is not to change the code very much that's one of tutorial told me to

`for(int i=0;i<strlen(Hz);i++)`

can yo give me an example to strlen in this and what it is suppose to be there?
Last edited on
strlen is a function that counts the number of characters in a c string.

example:
 ``1234`` ``````//correct const char a="foo"; // strlen returns 3 //incorrect char[] b="bar"; // error error b is an array! ``````

As for line 22, I would just do this:
 `` `` ``getline(cin, Hz, MHz);``

You should find a new tutorial....
what tutorial do you recommend?

also i've got few problems with code:

 ``1234567891011121314151617181920212223`` ``````errors:error: expected initializer before 'cout'| no matching function for call to 'getline(std::istream&, const char&, const char&)'| note: candidates are:| 1070|note: template argument deduction/substitution failed:| [2792|note: template std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&)| |2792|note: template argument deduction/substitution failed:| mismatched types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'const char'| |23|error: expected primary-expression before 'const'| |23|error: expected ';' before 'const'| |error: redeclaration of 'const char i'| |23|error: 'float i' previously declared here| 23|error: 'freq' was not declared in this scope| 23|error: increment of read-only variable 'i'| 24|error: expected primary-expression before 'const'| 24|error: expected ';' before 'const'| 24|error: redeclaration of 'const char x'| 24|error: 'float x' previously declared here| |24|error: increment of read-only variable 'x'| |25|error: invalid types 'const char[const char]' for array subscript| 25|error: invalid types 'const char[const char]' for array subscript| 24|warning: unused variable 'x' [-Wunused-variable]| |warning: unused variable 'i' [-Wunused-variable]| 35|error: expected '}' at end of input|``````

 ``1234567891011121314151617181920212223242526272829303132333435`` ``````#include #include using namespace std; float multiplies(float Hz, float Mhz); int main() { float add(float Hz); float multiple(float Mhz); const char Hz = 1000; const char MHz = 20000; cout << "please type in Keywords: "; getline(cin, Hz, MHz); for (float i=0
Last edited on
Well, the tutorial depends on what exactly you're tying to do. If you're looking for a language tutorial, see http://www.cplusplus.com/doc/tutorial/

Lines 13 & 14: Move them out of main() under line 6
Lines 15 & 16: How about const int instead of const char
Lines 22 and 23: add a { at the end of the line.
Line 31: change to a }

Also, the function freq is undefined, and multiplies, add, and multiple are declared but never defined or used.
i've tryed the tutuorial on c++ web site. is there tutorial on youtube that you can recommand? i'm more hands for understanding and also i'm using codeblocks.

also heres some errors that i've tryed to correct
 ``123456`` ``````19|error: 'cout' does not name a type| |20|error: expected constructor, destructor, or type conversion before '(' token| [23|error: expected unqualified-id before 'for'| [23|error: 'i' does not name a type| 24|error: 'x' does not name a type|``````

 ``1234567891011121314151617181920212223242526272829303132333435363738`` ``````#include #include float add(float Hz); float multiple(float Mhz); const float Hz = 1000; const float MHz = 20000; using std::cout; int main() { } cout << "please put in keywords:" << '\n'; getline (cin, Hz, MHz); for (float i=0
Last edited on
I'd just drop this program for now.
Tutorials...
Here's a sorta hands-on one: http://www.tutorialspoint.com/cplusplus/

I found it helpful to learn some other, more high-level languages before c++. Try codecademy's JavaScript course then come back to c++.
ok i've got this to work on adding

 ``123456789101112131415161718192021222324252627282930313233`` ``````#include #include #include using namespace std; int main() { std::string tone; std::cout << "please type in Keywords: "; std::getline(cin, tone); float Hz = tone.length(); float x; for (float x = 0; x < tone.length() ; x++) if (tone.at(x) == ' ' ); { Hz++; } std::cout << "Hz: " << Hz << endl; return 0; }``````

how do i get to this to loop back and multiply?
Last edited on
Line 25: remove the semicolon.
I don't really understand what you mean by multiply and loop back.
what i mean is to have the window still open while i am doing another key words counting and the console window is still open like in dos, multiplication. say that you have 10 x 10 = 100 . i did the addition for the you multiplying by times x. the problem is when i do ashtic it gets a error in code blocks for the newest version i'm on windows 10 x64.

i want this code to repeat=loop back code
Last edited on
Ok, I See.

Line 12: add `bool done=false;`
Line 13: add `while(done!=true)`
Line 14: add `{`
Line 29: add `std::string done2;`
 ``123456`` ``````std::cout >> "Finished? (Y/N)" >> std::endl; std::cin >> done2; if( (done2=="Y") || (done2=="y") ) { done=false; } //only Y matters, so no more checking ``````
Line 31: add `}`