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
ADVERTISEMENT
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
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
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
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
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
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
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
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
Nov 23, 2013
What the range of values and how to calculate them?
int Num = rand() % 350 + 13 / 10
View 2 Replies
View Related
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
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
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
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
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
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
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
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
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
View Related
Oct 24, 2013
I need to write a program that can calculate fractions.
View 2 Replies
View Related
Sep 10, 2013
How can i calculate a logarithm with my own base for example log on base 0.52 ?
View 2 Replies
View Related
Dec 16, 2013
I'm trying to calculate the size of values I've dynamically allocated memory to, i.e.
col_ind = new long[nz];
row_ptr = new long[inrows+1];
val = new double[nz];
from pointers. Now I've created the function,
int getmemsize(int i) {
int sizes[3];
sizes[0] = sizeof val;
sizes[1] = sizeof col_ind;
sizes[2] = sizeof row_ptr;
return sizes[i];
}
but each one is returning just the value 4? My arrays (one example) look like:
val = [ 5 2 5 9 8 3 9 10 9 ]
col_ind = [ 0 1 1 ]
row_ptr = [ 0 2 3 ]
View 6 Replies
View Related
Feb 15, 2015
My program suppose calculate postfix expression.
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.
View 8 Replies
View Related
Apr 1, 2013
What is the most efficient way to calculate Fibonacci. Is it recursion with memorization, is it iteration or is there another approach?
View 1 Replies
View Related
Apr 1, 2014
Is this the correct way to calculate the offset of a 3d array? Also is the dynamic allocation for it in the main program correct?
Some how it's not working fine after I input the values for some values of x,y,z e.g when the const ints are 2.
#include <iostream>
using namespace std;
const int x = 2;
const int y = 2;
[Code]....
View 8 Replies
View Related
Feb 27, 2015
I added my assignment to attachment, i need to calculate the sum for input values of x and n this is my code:
#include<stdio.h>
#include<math.h>
main() {
float gore,dole,s,x;
int n,i,j,z;
s=0;
i=0;
j=0;
[Code] ....
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 ....
View 6 Replies
View Related