0

error: expected primary-expression before 'float'

Hey guys I'm new to c++ and I don't know what I'm doing wrong.Can anyone help please. #include <stdio.h> #include <math.h> int main() { float y, x; float root1, root2 float root_part, root_denom printf('Enter the values of y, x'); scanf('%f%f', &y, &x); root1 = 2.0 * cos (y * y * sqrt(2.0 * x)); root_part = 4.0 * x + 3.0; root_denom = 3.0 * x * x + 2.0 * y + 4.0; root2 = sin * y f = root1 + ( root_part / root_denom ) + root2 printf('f = %.3f', f) return 0; }

11th Mar 2022, 9:26 PM
TaJoX
7 odpowiedzi
0
You are using [ ] squire brackets but need to use curly brackets { } int main{ // code } put semicolon ; at the end of each expression. and use double quotes " " in printf.... edit: TaJoX
11th Mar 2022, 9:34 PM
Jayakrishna 🇮🇳
+ 1
If you want run this in c++ here, then add iostream header and ask input by cin>>y>>x; instead of scanf(".. ") ; then it works fine. don't change original question.. add updates in reply, if you need.. hope it helps..
11th Mar 2022, 9:49 PM
Jayakrishna 🇮🇳
+ 1
okay thank you I'll try to change it
11th Mar 2022, 9:50 PM
TaJoX
0
I changed it but I still get error messages
11th Mar 2022, 9:37 PM
TaJoX
0
I don't know what's wrong but it stil doesn't work
11th Mar 2022, 9:42 PM
TaJoX
0
#include <stdio.h> #include <math.h> int main() { float y, x; float root1, root2; float root_part, root_denom; printf("Enter the values of y, x"); //1 scanf("%f%f", &y, &x); //2 root1 = 2.0 * cos(y * y * sqrt(2.0 * x)); root_part = 4.0 * x + 3.0; root_denom = 3.0 * x * x + 2.0 * y + 4.0; root2 = sin(x * y); //3 float f = root1 + ( root_part / root_denom ) + root2; //declare f printf("f = %.3f", f); return 0; } /* but it's a complete c code. Works in c++ also. But not properly work for input taking here , unless you have a cin. run it in c. In your code, corrected mistakes are : //1, 2 : are wrong quotes errors //3 : is incomplete sentence f is undeclared */
11th Mar 2022, 9:46 PM
Jayakrishna 🇮🇳
0
You're welcome..
11th Mar 2022, 9:51 PM
Jayakrishna 🇮🇳