0

The code doesn’t work

#include <stdio.h> double getVolumeOfCubiod(double length, double width, double height) { // Your code here... char ength; scanf("%c\n", &ength); char idth; scanf("%c\n", &idth); char eight; scanf("%c\n", &eight); char res; printf ("%c\n" * "%c\n" * "%c\n" = "%c\n", ength, idth, eight, res); return 0; } I need to multiply 3 variables, but the code doesn’t work. “Invalid operands to binary expression ('char [4]' and 'char [4]') Pls help me to debug the code

18th May 2022, 5:06 PM
Матвей Барканов
Матвей Барканов - avatar
5 Answers
0
Матвей Барканов how you are giving value to double type variables? Where is your main function? Actually where is your error expression? edit: Oh. What are you trying here? printf ("%c\n" * "%c\n" * "%c\n" = "%c\n", ength, idth, eight, res); It's invalid
18th May 2022, 5:13 PM
Jayakrishna 🇮🇳
0
I correct to “double”, but its not working again
18th May 2022, 5:17 PM
Матвей Барканов
Матвей Барканов - avatar
0
I edited my reply see again. But it work without main function.. Where is your main function..? " ... " * "... " Means multiplying string by string, which is invalid.. If you are trying to multiply two variables x, y then write like x * y and store result in a variable or display.. Why you need variables length, width, height there? Is that your full code? You must add main function.. Save full code in playground and share link here..
18th May 2022, 5:23 PM
Jayakrishna 🇮🇳
18th May 2022, 5:30 PM
Матвей Барканов
Матвей Барканов - avatar
0
#include <stdio.h> int main(){ //main function start // Your code here... double ength; //declaring double variable scanf("%lf\n", &ength); //reading value. double idth; scanf("%lf\n", &idth); double eight; scanf("%lf\n", &eight); double res = ength * idth * eight; // multiplying 3 numbers and storing result in res. printf("%lf * %lf * %lf = %lf", ength, idth, eight, res); // dispalying %lf is replaced by its corresponding value from arguments. . remaining all are just strings literals.. return 0; } // end // hope it helps..
18th May 2022, 5:39 PM
Jayakrishna 🇮🇳