Breaking out of function in c++ -


how leave function in middle? have condition leaving function, dont know how leave.

ex:

void a(int &num){     if (num > 100){         // leave function     }     num += a(num + 1); } 

i want end recursion, , have keep function void

void a(int &num){     if (num > 100){         return;     }     num += a(num + 1); } 

as pointed in comments martin york, jumped on answer without considering every aspect of question, , apologize. want :

int a(int num) {     if (num > 100)          return num;     return num + a(num + 1); } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -