Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links


Something is wrong with my C++ code. Plz help

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 26-10-2011
Member
 
Join Date: Oct 2011
Posts: 3
Something is wrong with my C++ code. Plz help

Sponsored Links
I am trying to use the Simpson's Method to calculate area under the curve using this function 2x^2+x but its not working?

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]

Reply With Quote
  #2  
Old 27-10-2011
Member
 
Join Date: Mar 2011
Posts: 152
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...
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 02:58 PM.