+ 1

How could i make this code to work

The error message displayed is " no matching function call+ no conversion of const char to int" How can i correct this: #include <iostream> #include <vector> using namespace std; int height, width{}; char symbol; void square(int height, int width, int symbol){ for (int h = 0; h< height; h++) { for (int w =0; w< width; w++){ cout << symbol << " "; } } } int main() { // cout << " Height " ; // cin >> height; // cout << " Width"; // cin >> width; // cout << "symbol"; // cin >> symbol; cout << square(5,6,"+"); return 0; }

1st Nov 2021, 9:40 AM
Reynolds Onyango
Reynolds Onyango - avatar
3 Respostas
+ 1
Thank you sir
1st Nov 2021, 10:12 AM
Reynolds Onyango
Reynolds Onyango - avatar
0
#include <iostream> #include <vector> using namespace std; void square(int height, int width, char symbol){ for (int h = 0; h< height; h++) { for (int w =0; w< width; w++){ cout << symbol << " "; } cout<<endl; } } int main() { // cout << " Height " ; // cin >> height; // cout << " Width"; // cin >> width; // cout << "symbol"; // cin >> symbol; square(5,6,'+'); //pass only matched type values, if you passing "+" then use string symbol in defination //square(5,7,"+"); then use function like void square(int height, int width, string symbol){ ...} And it returning nothing so nothing to display by cout<<square(5,7,'+') ,remove cout. Just call function. return 0; }
1st Nov 2021, 10:03 AM
Jayakrishna 🇮🇳
0
You're welcome ...
1st Nov 2021, 10:13 AM
Jayakrishna 🇮🇳