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.
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) {
Ex. 5 4 + 3 10 * + the answer is 39 because if I change it to infix, it's (5 + 4) + (3 * 10)
I need to use vector to compute the value. Here is what I think. First, I save leftmost from the string. If it is a number, I push. If that is a operation, I pop twice and push the result. By doing it until the string is emptied, the vector will only contain the final answer. And here is my code
#include <iostream> #include <vector> #include <string> using namespace std; int main(){ vector<int> stack; string input;
[Code] .....
When I put 1 1 + or 2 2 +, it showing me a correct answer, but when I put the above example which is 5 4 + 3 10 * +, it shows 30 instead of 39.
gore calculates x^(2*i)-3 and dole is for (2+i)! for input x=1 and n=1 i get -2.0 output which is the value of x^(2*i)-3 the (2+i)! part gets ignored for some reason, for any other input i tried the output is 0 ....