Category : double

I get a negative output to a positive double variable. My object is: Fahrzeug fr("BMW",200.45); class Fahrzeug { private: string p_sName; double p_dMaxGeschwindigkeit; public: Fahrzeug(string p_sName, double p_dMaxgeschwindigkeit) { this->p_sName = p_sName; this->p_dMaxGeschwindigkeit = p_dMaxGeschwindigkeit; //the output is negative cout << "Der Name des Fahrzeugs: " << this->p_sName << "n" << "Die maximale Geschwindigkeit des ..

Read more

#include<iostream> #include<cmath> using namespace std; float san= 0.25 ; float var= 0.75; int findFact(int n)//factorial { return n == 1 ? 1 : n * findFact(n – 1); } int findNcR(int n, int r)//combination nCr { return findFact(n) / (findFact(n – r) * findFact(r)); } double prob(int s, int v){ //recursive function for probability if(s==5) ..

Read more

I am running a simulation in C++ where I need to calculate values under a loop which runs from 0 to 10 seconds but each increment is of 10ms i.e. for(i=0;i<=10;i+=0.01). The statement under this loop calculate the values for a variable , say "velocity at time time ‘t’ = vt’ where ‘t’ is equal ..

Read more