im new to coding (currently learning c) and doing lessons online, using codeblocks and W3 schools. started getting into if…else statements. This is the first if..else with an (else if) in it ive done and cant figure out what ive done wrong for the error codes to come up
- 420|int time3 = 44;
- 421|if(time3 < 30){
- 422| printf(“works?”);
- 423|}else if (time3<40){
- 424| printf(“kinda works”);
- 425|}else{
- 426| printf(“maybe works”);
- 427| }
- 428| }
- 429|}
This ^^^^code and code before
Build file: “no target” in “no project” (compiler: unknown) ===|
C:Usersto4d8Documentsmyfirstprogram.c||In function ‘main’:|
C:Usersto4d8Documentsmyfirstprogram.c|25|warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]|
C:Usersto4d8Documentsmyfirstprogram.c|25|warning: incompatible implicit declaration of built-in function ‘printf’|
C:Usersto4d8Documentsmyfirstprogram.c|25|note: include ‘<stdio.h>’ or provide a declaration of ‘printf’|
Code around line 25 for line 25 error
C:Usersto4d8Documentsmyfirstprogram.c|420|error: expected identifier or ‘(‘ before ‘if’|
C:Usersto4d8Documentsmyfirstprogram.c|422|error: expected identifier or ‘(‘ before ‘else’|
C:Usersto4d8Documentsmyfirstprogram.c|424|error: expected identifier or ‘(‘ before ‘else’|
C:Usersto4d8Documentsmyfirstprogram.c|427|error: expected identifier or ‘(‘ before ‘}’ token|
C:Usersto4d8Documentsmyfirstprogram.c|428|error: expected identifier or ‘(‘ before ‘}’ token|
||=== Build failed: 5 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
error log
I have tried to put #include <stdio.h> but when that happens its own set of code breaks, if i remove it everything is fine. Kinda dont know what to do after that so kinda stopped.
stdio.h errors
matt moser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.