let total & num be clobal variables