|
| ||||||||||
| Tags: c plus plus, c programming, programming code |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Something is wrong with my C++ code. Plz help
Can some one help me and fix the problem? Its using Simpson's Method and want user to input a,b and N then calculate the area of the function given 2x^2+x [code] #include <stdio.h> #include <conio.h> #include <cstdlib> double simpson(double a, double b, int n); double fk(double x); //********************************** int main() { double a,f,b; int n; //Duomenys---------------- printf("Enter value of a, example a=0\n a:"); scanf("%lf", &a); //------------------------ printf("Enter value of n, example n=7\n n:"); scanf("%d",&n); printf ("Enter Value of b, example b=1\nb:"); scanf("%lf", &b); f=simpson(a ,b , n); // Integralas //Rezultatas---------------- printf("The result is f=%7.2f\n",f); } //********************************** double simpson(double a, double b, int n) { double c= (a+b)/2.0; double h3= abs(b-a)/6.0; double result= h3*(fk(a)+4.0*fk(c)+fk(b)); return result; } //********************************** double fk(double x) { return x * x; } /[code] |
|
#2
| |||
| |||
| Re: Something is wrong with my C++ code. Plz help
Are you sure its a C++ code. according to my knowledge its a C code. please correct me if i am wrong... |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Something is wrong with my C++ code. Plz help" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Code for downloadable content of Alan Wake is wrong | VARIJ | Video Games | 1 | 18-02-2012 07:15 PM |
| Vb.net **what Is Wrong With This Code** | Programmer666 | Software Development | 1 | 30-12-2011 02:03 AM |
| Apple sent me Wrong IMEI/Unlock Code for Iphone 4 | GPower | Portable Devices | 5 | 27-12-2011 01:29 PM |
| I am getting wrong bonus code message in Assassins creed brotherhood | Althea | Video Games | 5 | 27-03-2011 11:00 PM |
| Wrong Activation Code, activation issues | Lawford | Networking & Security | 4 | 11-04-2010 12:41 AM |