```/* D01BD_A1W_F C++ Header Example Program.
*
* Copyright 2019 Numerical Algorithms Group.
* Mark 27, 2019.
*/

#include <nag.h>
#include <dco.hpp>
#include <stdio.h>
#include <math.h>
#include <nag_stdlib.h>
#include <nagx01.h>
#include <iostream>
using namespace std;

extern "C"
{
static void NAG_CALL f(void * &ad_handle,
Integer iuser[],
}

int main(void)
{
// Scalars
int               exit_status = 0;

cout << "D01BD_A1W_F C++ Header Example Program Results\n\n";

// Skip first line of data file
string mystr;
getline (cin, mystr);

double            ar, br, epsabsr, epsrelr;
cin >> ar;
cin >> br;
cin >> epsabsr;
cin >> epsrelr;

a = ar; b = br; epsabs = epsabsr; epsrel = epsrelr;

// Create AD configuration data object
Integer ifail = 0;

Integer           iuser[1];

ruser[0] = 10.0;
iuser[0] = 0;

// Register variables to differentiate w.r.t.

ifail = -1;
iuser,ruser,ifail);

// Print inputs and primal outputs.
cout << "\n lower limit of integration (a) = " << ar << endl;
cout << " upper limit of integration (b) = " << br << endl;
cout << " absolute accuracy requested    = " << epsabsr << endl;
cout << " relative accuracy requested    = " << epsrelr << endl;
cout.setf(ios::scientific,ios::floatfield);
cout.precision(4);
if (ifail >= 0) {
cout << "\n approximation to the integral  : " << nagad_a1w_get_value(result) << endl;
cout << " estimate of the absolute error : " << nagad_a1w_get_value(abserr) << endl;
cout << " number of function evaluations : " << iuser[0] << endl;
}

// Setup evaluation of derivatives via adjoints.
double inc = 1.0;
ifail = 0;

cout << "\n Derivatives calculated: First order adjoints\n";
cout << " Computational mode    : algorithmic\n";

// Get derivatives

cout << "\n Derivative of solution w.r.t to ruser[0]:\n";
cout << " d/dr(x) = " << dr << endl;

// Remove computational data object and tape

return exit_status;
}

static void NAG_CALL f(void * &ad_handle,
Integer iuser[],
{
// dco/c++ used here to perform AD of the following
double pi = X01AAC;