What's wrong with this code? Sorry, I'm beginner | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

What's wrong with this code? Sorry, I'm beginner

#include<stdio.h> #include<stdlib.h> #include<math.h> float sum (int, int,float,float,float,float); float (int m,float z, float b,float c, float d); {float S=0; int k; for(k=m, k<=m; k++) {S+=((z*k*k*k+b+c*k+d)+(z*k*k*k+b+c*k+d))/(z*k*k*k+b+c+d); } return(S); } int main() y=(2*(sum(1,m,1,0,0,2))+a*sum(1,m,1,0,0,3))/(6*sum(3,m,5,0,0,a)); printf ("\n y=%.3f", y); return(0); }

9th Jan 2019, 6:26 PM
Ева
4 Antworten
+ 2
There are many wrong things in this code. For example, in main you have variables m and a that aren't defined. Syntax isn't good etc. I don't know what you want this program to do so I can't help you. Try explaining what it should do and I'll help you more.
9th Jan 2019, 8:19 PM
Mina
Mina - avatar
+ 2
Please. Format your code. Pay attention to your parameters. I don't mean to be rude, but this is actually horrible. I've never seen worse formatting than this. Fix it, and then I'll help. Also explain what you're trying to do.
9th Jan 2019, 8:22 PM
Rain
Rain - avatar
+ 2
Seems you tried doing hard things and copied some code, before understanding the logic behind c++. This isn't a good practice and you should focus on understanding the basics. It is like learning a new language and speaking with your pc in it. Try to think of ot more abstractly, as if it were a person. The compiler doesn't know what you mean by saying float {int... For example. You either wouldn't understand what i meant if i said bring me the {missing code} which has liquid in it containing milk, later, etc. Just grasp the logic first, understand and ask yourself why, after that go and do harder things to challenge yourself. Good luck!
9th Jan 2019, 9:38 PM
Denis Cvetanov
Denis Cvetanov - avatar
+ 1
Thanks, I found all mistakes
9th Jan 2019, 8:25 PM
Ева