Help me to find mistake in my code

http://codeforces.com/problemset/problem/260/A

#define _GLIBCXX_DEBUG//Iterator safety; out-of-bounds access for Containers, etc.
#include<bits/stdc++.h>
#pragma GCC optimize "trapv"// abort() on (signed) integer overflow.
using namespace std;


int main(){
 int a,b,n,l;
 cin>>a>>b>>n;
 if(n==0)
    cout<<a;
 else{
        bool flag=false;
        for(int k=0;k<=9;k++){
            string s=to_string(k);
            string h= to_string(a);
            int l=stoi(s+h);
            if(l%k==0) {
                a=l;
                flag=true;
                break;
            }
        }
        if(flag){
                int x=n-1;
                cout<<a;
                while(x--) cout<<"0";
        }
        else cout<<"-1";

 }
return 0;
}

It crashes on the sample input:

[simon@simon-laptop][07:21:29]
[~/devel/hackerrank/otherpeoples]>g++ -std=c++17 prince_000-codeforces-blah.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -fsanitize=undefined -ftrapv
prince_000-codeforces-blah.cpp: In function β€˜int main()’:
prince_000-codeforces-blah.cpp:8:15: warning: unused variable β€˜l’ [-Wunused-variable]
     int a,b,n,l;
               ^
[simon@simon-laptop][07:21:36]
[~/devel/hackerrank/otherpeoples]>echo "5 4 5" | ./a.out
prince_000-codeforces-blah.cpp:18:17: runtime error: division by zero
Floating point exception (core dumped)
1 Like

why codeblocks , dont show this type of errors

but sir it is still showing error , please check my approach also