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) {
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;
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).
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.
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.
#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
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.
// 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?
// 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.
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.
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;
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 {
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 ()
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;
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 . ....
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} .
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);
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.