[ create a new paste ] login | about

Link: http://codepad.org/57EDP4z0    [ raw code | output | fork ]

C++, pasted on Jan 21:
#include <assert.h>
#include <iostream>

using namespace std;

int division(int a, int b) {
    if (b==0) {
        cerr << "Error at line " << __LINE__ << " in file " << __FILE__ << endl;
    }
   assert(b!=0);
   return (a/b);
}

int main () {
   int x = 11;
   int y = 0;
   int z;

   z = division(x, y);
    
   cout << "Answer is " << z << endl;

   return 0;
}


Output:
1
2
3
4
Error at line 9 in file t.cpp
t: t.cpp:11: int division(int, int): Assertion `b!=0' failed.

Disallowed system call: SYS_kill


Create a new paste based on this one


Comments: