.exe has stopped runnung

Greetings! :)
Can you please tell me why does windows says ".exe has stopped running" after i give values for the two int that goes to cin?
(I am using codeblocks)
The program has to decide if 2 given numbers are friendly or not.
Thank you for your help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
using namespace std;

bool friendly (int a, int b){
    bool def=false;
    int suma=0;
    int sumb=0;
    for (int i=0; i<a; i++){
        if((a%i)==0){
            int suma=suma+1;
        }
    }
    for (int i=0; i<b; i++){
        if((b%i)==0){
            int sumb=sumb+1;
        }
    }
    if (sumb==a && suma==b){
        def=true;
    }
    return def;
    }
int main()
{
    int a,b;
    cout << "Please give two integer numbers separated by a space" << endl;
    cin>> a >> b;
    if (friendly(a,b)==true){
        cout<<"The two given numbers are friendly!"<<endl;
    }
    else{
        cout<<"The two given numbers are not friendly!"<<endl;
    }
    return 0;
}
if((a%i)==0){
Division by 0.
Thank you integralfx! :)
Topic archived. No new replies allowed.