I have a problem with the following code
#include <stdio.h>
int main() /* Tidsberäkning YO */
{
float tid1, tid2;
printf("Tid i första åket? ");
scanf("%f", %tid1);
printf("Tid i andra åket? ");
scanf(%f", &tid2);
printf("Total Tid: %f\n", tid1+tid2);
printf(Genomsnittlig tid: %f\n", (tid1+tid2)/2);
}
And here is the error log
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(6): error C2059: syntax error : '%'
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(8): error C2143: syntax error : missing ')' before '%'
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(8): error C2198: 'scanf' : too few arguments for call`
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(8): error C2001: newline in constant
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(8): error C2065: 'f' : undeclared identifier
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(8): error C2143: syntax error : missing ';' before 'string'
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(8): warning C4552: '%' : operator has no effect; expected operator with side-effect
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(9): error C2146: syntax error : missing ';' before identifier 'printf'
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(10): error C2065: 'Genomsnittlig' : undeclared identifier
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(10): warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int'
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(10): warning C4024: 'printf' : different types for formal and actual parameter 1
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(10): error C2146: syntax error : missing ')' before identifier 'tid'
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(10): error C2017: illegal escape sequence
c:\users\shaggydoo\documents\visual studio 2010\projects\ilikecake\ilikecake\hellobro.c(10): error C2001: newline in constant
scanf(%f", &tid2);and
printf(Genomsnittlig tid: %f\n", (tid1+tid2)/2);are missing the first quotation mark. Change to:
printf("Genomsnittlig tid: %f\n", (tid1+tid2)/2);and
scanf("%f", &tid2);