double exp(double t)??



  • Hallo zusammen,

    kurze Frage: Wieso bekomm ich beim folgenden Code diesen Fehler angezeigt:

    In function int main() expected primary expression before double, expected ) before double.

    ich habe schon alles mögliche versucht, aber irgend was haut mit dem "exp" nicht hin.

    #include <cstdlib>
    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    int main()
    {
        int s,l;
        double result,x;
    
        cout << "Bitte geben Sie einen Ganzzahlwert für s und Lambda l ein:" << endl;
        cin >> s, l;
    
        double f = pow(l,8.0);
        double r = pow(s,8.0);
        double t = (-3.31488 * f)/r;
        double exp(double t);
    
        if (s=0)
        {
                cout << "1" << endl;
        }
        else
            result = 1 - (double exp(double t));
            cout << result << endl;
    
        system("PAUSE");
        return 0;
    }
    

    Vielen Dank schonmal fürs anschaun:)
    v



  • willst du die funktion exp aus cmath benutzten??
    dann must du nur das schreiben:

    result = exp(t);
    

    http://www.cplusplus.com/reference/clibrary/cmath/exp/



  • hatte es schon mit math.h. war eins der sachen, die ich versucht habe zu ändern durch stöbdern in diversen tutorials und büchern...



  • ach du liebe zeit, es funktioniert:))) danke dir



  • ich verstehe nicht was du mit

    vankitz schrieb:

    double exp(double t);
    

    willst

    versuch es mal so:

    #include <cstdlib> 
    #include <iostream> 
    #include <cmath> 
    
    using namespace std; 
    
    int main() 
    { 
        int s,l; 
        double result; 
    
        cout << "Bitte geben Sie einen Ganzzahlwert für s und Lambda l ein:" << endl; 
        cin >> s;
    	cin >> l;
    
        double f = pow(l,8.0); 
        double r = pow(s,8.0); 
        double t = (-3.31488 * f)/r; 
    
        if (s==0) 
    		cout << "1" << endl; 
        else 
            result = 1 - exp(t); 
            cout << result << endl; 
    
        system("PAUSE"); 
        return 0; 
    }
    

Anmelden zum Antworten