Mercurial > MadButterfly
comparison examples/calculator/main.c @ 89:90428161fc61
Prevent divide by zero error
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 23 Aug 2008 15:39:29 +0800 |
parents | dd813dcc232c |
children | bd29780bf266 |
comparison
equal
deleted
inserted
replaced
88:dd813dcc232c | 89:90428161fc61 |
---|---|
45 break; | 45 break; |
46 case '*': | 46 case '*': |
47 r = v1 * v2; | 47 r = v1 * v2; |
48 break; | 48 break; |
49 case '/': | 49 case '/': |
50 r = v1 / v2; | 50 if(v2) |
51 r = v1 / v2; | |
52 else | |
53 r = v1; | |
51 break; | 54 break; |
52 } | 55 } |
53 | 56 |
54 return r; | 57 return r; |
55 } | 58 } |