vendredi 22 octobre 2021

why is assignment to expression with array type failed in ternary function

I have written this program many times in different ways but I am not getting the output and am unable to find out the error, is there anyone who can point out the logical error in this program?

#include<stdio.h>
#include<string.h>

int main()
{
    float temp;
    char c[15]; 
    
    printf("Enter temperature in F degree=");
    scanf("%f",&temp);
    
    c = (temp>=80    ? strcpy(c,"swimming"):
        (60<=temp<80 ? strcpy(c,"tennis"):
        (40<=temp<60 ? strcpy(c,"Golf"):
                       strcpy(c,"skiing 1."))));    
    
    printf("%s",c);
}

Aucun commentaire:

Enregistrer un commentaire