PC kann nicht rechnen



  • Moin habe folgendes programm geschrieben es kommen aber unterschiedlicher ergebnisse raus frage is warum?

    */
    Programm: Geschwindigkwitskonstante k
    Autor 	: **
    */
    
    #include <iostream.h>
    #include <math.h>   //für exp funktion
    #include <ctype.h>  //für toupper
    
    int toupper(int ch);      //funktion touppert
    double exp(double x);     //funktion exp
    
    	int main ()
    
    	{
    
        	char c='J';
    		while(toupper(c)=='J')
    		{
    
    		/*
    		Formel um k zu berechnen!!
    		k=(R*t/N*h) * exp (-dG/(R*t))
    		*/
    
    		double t,dG,R,N,h,k;
    
        	cout << "Bitte Temperatur in Kelvin angeben" << endl;
        	cin >> t;
        	cout << "Bitte delta G in J/mol angeben   " << endl;
        	cin >> dG;
    
       	 	R=8.314;
        	N=6.022e23;
        	h=6.6e-34;
    
            //kontrolle
            double p,d,v;
            p=6.129e12;
            d=-24.6305;
            v=p*exp(d);
    
            cout << "Kontrolle eins sagt: " << v << endl;
    
        					//Alle einfachen Variablen initialsiert
    
        	k = (R*t*exp(-dG/(R+t)))/(N*h);
    
        	cout << "k= " << k << endl;
        	cout<<"nochmal rechnen (J/N)?";
      		cin>>c;
    
        	}
    

    return (0);
    }



  • Troll!



  • was meinst du mit "unterschiedliche Ergebnisse"?



  • naja für v und k gibt er andere werte aus.
    Obwohl es die selben sein sollten



  • float a = 0.099999999 * 10;
    float b = 1;

    => a == b (!)

    floats sind lustig was? 😉


Anmelden zum Antworten