function and serial

hello im kinda new to arduino but i dont understand wtf is going one can some one explain me (sorry for bad english)

unsigned long var = 0;
unsigned long var2 = 55;


void setup() {
Serial.begin(9600);
}

void loop() {

if(fun() == true){
Serial.println("function return TRUE"); 
}

}


int fun(){
Serial.println(var); /// if i print this function will return me a TRUE
Serial.println(var2); /// but if i print this then function will return me a false 
  }

Ehm, in this sketch it looks like it's impossible to get 'fun' to 'true' also you can't use == true in this sketch in the if expression.. You use the true and false in boolean's.

If you had enabled the warnings, the compiler would have told you

C:\Users\noReturn.ino: In function 'int fun()':

C:\Users\noReturn.ino:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
int fun() {
  Serial.println(var);  // no impact on result
  Serial.println(var2); // no impact on result
  return 0; // always false
}

Ehm, in this sketch it looks like it's impossible to get 'fun' to 'true' also you can't use == true in this sketch in the if expression.. You use the true and false in boolean's.

Not true. While comparison to true or false is usually only done with booleans, they values can be stored in ints or bytes or chars.

OP: You lied when you said that fun() would return an int. You either must add a return statement or change the function return type to void.