C++ :: Calculate Integral Using Rectangles

Feb 13, 2013

I have a function written to calculate an integral using rectangles. I get this error: 'cannot convert double to double (*) (double) in assignment'. But whenever I remove one of the doubles something is undeclared.

double rect_integral(double a, double b, int n, int f) {

double x;
double (* fx) (double);

double func_1 = 5*(pow(x,4))+3*(pow(x,2))-10*(x)+2;
double func_2 = pow(x,2)-10;

[Code] .....

View 3 Replies


ADVERTISEMENT

C# :: Draw Multiple Rectangles With Mouse In Picturebox

Jun 6, 2014

I am trying to build a WinForm application that will allow you to load an image into a picturebox and then draw multiple rectangles (empty or translucent) to kind of highlight areas. I want all the rectangles to stay on the image (i can take care of a clear method later). The code below has the latest two attempts I've tried. One is all commented out and the other is not. Both will load the image just fine but neither will allow me to draw/select rectangles on the image.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;

[Code] ....

View 14 Replies View Related

C :: How To Evaluate Double Integral

Oct 6, 2014

I am very new to programming and would like to know where to even start when evaluating a double integral. I wanted to evaluate this double integral: 6x^3 + y^2 +7x from 0 to 1 (for both).

View 1 Replies View Related

C :: Trapezoidal Approx Of An Integral

Aug 2, 2013

One of my last programs to write was to use the trapezoidal rule to approx. the definite integral defined in the program. It works, now i am looking for ways to improve this code, if there are any.

Code:
#include<stdlib.h>#include<stdio.h>
#include<math.h>
double integral (double x);
int main(void){

[Code] ....

the output is simple:

Code: ssma-imac:ENG-3211 ssma$ ./integralThe integral of x^2 Sin(x) dx from 1 to 5 is -18.953841

And yes this is a very good approximation of the actual integral.

View 9 Replies View Related

C++ :: Const Static Integral Members

Jan 16, 2014

I've been having a problem concerning the initialization of const static integral members with floating point calculations. I'll let his sample program do the explaining:

class Foo {
public :
Foo() {}
const static int samplerate = 44100;
const static unsigned short tempo = 120;

[Code].....

I know you can't initialize const static non-integral types on the same line on which they're declared, but I don't see why even an implicit cast to an integral type should be disallowed. I make my calculations using doubles, so I'm surprised that even though it should degenerate into an integer - it's still a problem for the compiler.

View 1 Replies View Related

C++ :: Error / Expression Must Have Integral Or Enumtype

Mar 19, 2013

Code:

#include <iostream>
#include <iomanip>
using namespace std;
//chose to use #define since columns/rows are a constant in the program
#define x 5
#define y 3
int main() {
//declare variables

[code]....

View 8 Replies View Related

C++ :: How To Use Templated Varadic Sequences And Integral Sequence Wrappers

Jul 15, 2013

I've been studying the heck out of the boost metafunction libraries. I understand a good deal of what things like varadic functions and integral sequence wrappers are, but I am having a hard time putting everything together to get working functions, such as performing arithmetic operations or functions like that of std::vector.

Here is an example of what I'm talking about:

// Sequences
template<typename T... N> struct seq;
template<typename T, T... N> struct seq_c;

// Integral constant wrapper
template<int T> struct int_

[Code] .....

My knowledge of all of this is pretty scattered and I've really been trying hard to put it all together. Is this correct? How can I apply this and use it to do more?

View 5 Replies View Related

C++ :: IntelliSense - Expression Must Have Integral Or Unscoped Enum Type

Sep 6, 2014

So far I have the following code:

// Purpose: To write a program that displays the number of millimeters higher the current level the ocean level will be in
// in 5, 7, and 10 years.

# include <iostream>
# include <string>
using namespace std;
int main() {
float X = 10;
string Y="";

[Code] ....

But I get the following error message:

IntelliSense: expession must have integral or unscoped enum type

three times in a row for lines 25, 27, and 29 and I don't understand or know why?

In case the purpose does make sense here are the directions:

2.7: Ocean Levels

Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write a program that displays

•The number of millimeters higher than the current level that the ocean’s level will be in 5 years,
•The number of millimeters higher than the current level that the ocean’s level will be in 7 years,
•The number of millimeters higher than the current level that the ocean’s level will be in 10 years,

Output labels:

Each value should be on a line by itself, preceded by the a label of the form:

In X years the ocean's level will be higher by Y millimeters.

where X is the number of years (5, 7 or 10) and Y is the value you calculate.

View 16 Replies View Related

C :: Calculate Approximate Value Of E

Jul 12, 2013

I'm trying to write a program to calculate an approximate value of e using the formula e = 1 + 1/1! + 1/2! + ....... 1/n!...However, I'm always getting nearly 2.291481 as answer.Here is my code :

Code:

//Approximate the value of e
#include <stdio.h>
int main(void) {
int n, j;
printf("Please enter value of n : ");
scanf("%d", &n);

[code]....

I know I'm not supposed to use system("PAUSE"), but this is self-study.

View 8 Replies View Related

C++ :: Program To Calculate BMI

Oct 7, 2013

I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2

Here is my code

#include <iostream>
#include <cmath>
using namespace std;
int main() {
int weight;
int height;
double BMI;

[Code] ....

View 2 Replies View Related

C++ :: Calculate Something More Than A Var Can Handle?

Jan 1, 2013

Let's say I want to calculate something like PI using some algorithm, but with the number of digits I want to.

View 1 Replies View Related

C/C++ :: Calculate Sum Of Every Digit

Nov 22, 2014

I want calculate sum of every digit in my zip code so I wrote implementation function like that but, it shows "0" as answers, then I realize it should be call first, I add correctionDigitOf() in to constructor "Zipcode::Zipcode" then My zipcode are all "0' after I do this .....

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
#include <cmath>
using namespace std;
class Zipcode {

[Code] ....

View 1 Replies View Related

C/C++ :: Contributions Will Not Calculate

Aug 7, 2012

Contributions won't calculate ...

#include <stdio.h> 
#include <conio.h> 
int main()  { 
float tax;
 float salary;
 float taxable;
 float taxmo;
 float contributions;

[Code] .....

View 1 Replies View Related

C++ :: Calculate Area Of Circle Without Pi

Mar 22, 2013

I was given an assignment for class to calculate the area of a circle using only the radius as a user input and not using Pi in the code. I need to do this by calculating the areas of a series of rectangles under the curve and adding them together. Using nested loops to continuously reduce the size of these rectangles until the approximated area value is within a margin of error less than 0.1%.

Code:
#include<iostream>
#include<cmath>
using namespace std;
int main ()

[Code] .....

View 7 Replies View Related

C++ :: Calculate The Angle Between Two Vectors

Feb 20, 2014

My question is not in c++ programing , but because my aim is to make code that calculate the three angles between two vector i ask my question here

So as the title i have three point that create two vector and I want to get the angles in x,y and z of the point2

I used crosproduct that give me one angle without axe , I don't know in which axe this angle

My aim is the three angles for the 3 axes ....

View 7 Replies View Related

C :: Algorithm To Calculate Highest Value?

Aug 3, 2014

Now I know there's a simple way to calculate highest value. But here i have this algorithm which i understood part of it.

I know that *largest is point to the first element of begin which is 5. so in the first if statement its 5<5 at the first iteration ?

// i marked the parts i didnt understand with " //"

Code:
#include <stdio.h>
int *print(int *begin ,int *end ){
if(begin==end)
return 0;
int *largest = begin;

[Code] ....

View 10 Replies View Related

C :: Calculate Value Of PI With The Accuracy (EPS) Given By User

May 23, 2013

I have to calculate the value of PI with the accuracy (eps) given by the user. I started with this but I just got stuck now, I don't know what is going on with the code or why does it get stuck in the second iteration...

PHP Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){    
float eps=0.000001; 

[Code] ....

View 4 Replies View Related

C :: How To Calculate Range Of Values

Nov 23, 2013

What the range of values ​​and how to calculate them?

int Num = rand() % 350 + 13 / 10

View 2 Replies View Related

C++ :: Calculate Standard Deviation

Jul 11, 2014

I have a program that will calculate max, average, etc from a file of numbers. However, I cannot get it to calculate standard deviation.

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cmath>

[code]....

View 4 Replies View Related

C++ :: Calculate The Factorial With Function?

Jan 3, 2013

calculate the factorial with function

The program should then calculate the factorial of the number n, where n!= n×(n −1)...× 2×1

the output like this:

Enter number: 4
Factorial of 4! = 24
Enter number: 6
Factorial of 6! = 720
Enter number: 3
Factorial of 3! = 6
Enter number: 0
Factorial of 0! = 1
Enter number: -5
Factorial of -5! = -1
Press any key to continue . ....

View 7 Replies View Related

C++ :: Calculate Tax Of Vehicle With Polymorphism?

Dec 29, 2012

How can we calculate tax of vehicle with polymorphism? There are 3 types of vehicles: long, commercial, and private vehicles' classes. There is a common class about all vehicles.

BASE class:
1.Brand and series name (such as Toyota Corrolla, Isuzu etc.)
2.Year of production (you can term it model)
3.Engine size in dm3
4.Owner’s name (including surname) and identity
5.Plate number.

COMMERCİAL :
1.Number of seats (apart from the driver)
2.Data to indicate whether the commercial vehicle is allowed to operate at night.

LONG :
1.The tonnage (max load in tons)
2.Data to indicate whether the long vehicle is allowed to carry goods internationally.

PRİVATE:
1.The class label which can be one of {A,B,C} .

View 1 Replies View Related

C++ :: Calculate Mean Of Array Class?

Jan 16, 2013

I am trying to create a small function that can return the mean of an object of array class, not a simple array.

Declare and initiate the array:

array<double, 100> myArray = {};
myArray.fill(1.0);

function to calculate mean:

double mean_array(double *array)
{
double sum = 0.0;
for(int i=0; i<sizeof(array); i++)
sum += array[i];
return sum / sizeof(array);
}

However, it does not work. It seems it is incompatible with the array definition.

View 8 Replies View Related

C++ :: Calculate Distance Between Two Points

May 15, 2014

It ougth to calculate the distance between two point (p1,p2)

"main.cpp"
#include "distancia.h"
void main () {
Point p1,p2;

[code]....

View 4 Replies View Related

C++ :: Looping And Calculate The Percentage?

Mar 7, 2013

#include <iostream>
#include <iomanip>
#include <math.h>

[Code].....

I AM HAVING TROUBLE CALCULATING THE PERCENTAGE. I HAVE TO CALCULATE THE AMOUNT OF MONEY FOR 6 YEARS.

View 1 Replies View Related

C++ :: How To Calculate Number Of Scores Above 90

Apr 7, 2013

I have a program that allows the user to enter a specific number of test scores. Based on these test scores, the program should display the average score and calculate how many of the scores were above 90. I have most of it done but I'm having trouble figuring out how to calculate the number of scores that were above 90. What am I doing wrong?

This is my code:

#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
double average(double*, int);
int howManyA(double*, int);

[Code]...

View 1 Replies View Related

C++ :: Calculate Sum Of Numbers In Given Positions

Dec 16, 2013

Question: Write a program that calculates sum of the numbers in the given positions.

Input specification : There will be 4 lines of data. You will be first given the size of the positions array (n). Then, the following line will have n integers which is an ordered list in increasing order and 0 < n ≤ 3000. The third line will give the size of the number array (m) where 0 < m ≤ 5000 and The last line will have m integers between -30000 and 30000.
Note: The positions start from 1 and goes until m.

Output specification : Show one integer number. Sum of the Numbers in the given Positions.

Sample Input I
5
2 5 7 9 10
10
1 8 7 5 17 15 6 7 19 12

Sample Output I
62

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved