Can somebody help me, why this aren't working?
I always get: else without a previous if
PS: I'm from Austria, sorry for my bad English :)

#include <stdio.h>

int main(void)
{
    int w;
    double v, s, t;

    printf("Dieses Programm berechnet Geschwindigkeiten, Wegdifferenzen und\n"
            "Zeitdifferenzen fuer eine gleichfoermige Translation.\n"
            "1 ... Berechnung der Geschwindigkeit\n"
            "2 ... Berechnung der Wegdifferenz\n"
            "3 ... Berechnung der Zeitdifferenz\n");
    printf("Bitte waehlen Sie aus:"); scanf("%d", &w); getchar();

    if  (w = 1)             printf("Wegdiffernz (in m):\n");        scanf("%lf", &s);   getchar(); 
                            printf("Zeitdiffernz (in s):\n");       scanf("%lf", &t);   getchar(); 
                            (v = s / t);
                            printf("Ergebnis:\n Geschwindigkeit: %lf m/s", &v);

    else if  (w = 2)        printf("Geschwindigkeit (in m/s):\n");  scanf("%lf", &v);   getchar();
                            printf("Zeitdiffernz (in s):\n");       scanf("%lf", &t);   getchar();
                            (s = v * t);
                            printf("Ergebnis:\n Wegdifferenz: %lf m", &s);

    else if (w = 3)         printf("Geschwindigkeit (in m/s):\n");  scanf("%lf", &v);   getchar();
                            printf("Wegdiffernz (in m):\n");        scanf("%lf", &s);   getchar();
                            (t = v * s);
                            printf("Ergebnis:\n Zeitdifferenz: %lf s", &t);             
    return 0;
}

Hi, Hermelix welcome here at Daniweb! :)
Der Danny von Belgien!
Your main problem at frist glance, is a lack of curly braces.
You can omit them if your if statement only has one line.
If you have many lines you have to use them.
I ALWAYS use them

if (condition)
{
line1;
line2; etc.
}
else if (condition)
{
and so on
}

Hope it helps.

Here's your code, formatted and with curly braces as ddanbe explained.

    #include <stdio.h>

    int main(void)
    {
        int w;
        double v, s, t;

        printf("Dieses Programm berechnet Geschwindigkeiten, Wegdifferenzen und\n"
        "Zeitdifferenzen fuer eine gleichfoermige Translation.\n"
        "1 ... Berechnung der Geschwindigkeit\n"
        "2 ... Berechnung der Wegdifferenz\n"
        "3 ... Berechnung der Zeitdifferenz\n");
        printf("Bitte waehlen Sie aus:"); scanf("%d", &w); getchar();

        if (w = 1)
        {    
            printf("Wegdiffernz (in m):\n");        
            scanf("%lf", &s);   
            getchar(); 
            printf("Zeitdiffernz (in s):\n");      
            scanf("%lf", &t);   
            getchar(); 
            (v = s / t);
            printf("Ergebnis:\n Geschwindigkeit: %lf m/s", &v);
        }

        else if (w = 2)
        {    
            printf("Geschwindigkeit (in m/s):\n");  
            scanf("%lf", &v);   
            getchar();
            printf("Zeitdiffernz (in s):\n");       
            scanf("%lf", &t);   
            getchar();
            (s = v * t);
            printf("Ergebnis:\n Wegdifferenz: %lf m", &s);
        }

        else if (w = 3)
        {    
            printf("Geschwindigkeit (in m/s):\n");  
            scanf("%lf", &v);   
            getchar();
            printf("Wegdiffernz (in m):\n");        
            scanf("%lf", &s);   
            getchar();
            (t = v * s);
            printf("Ergebnis:\n Zeitdifferenz: %lf s", &t);
        }

        return 0;
    }

Big thank you, now it work's :)

Hermelix, mark this thread as solved please

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.