extended euclid and modular linear equation

I know i posted similar code in another thread,but i have a new problem so bear with me. Im trying to get my extednded euclid code to work with my modular linear equation solver.
the code i have:
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <iostream>
//#include<fstream>
using namespace std; 

int gcd(int a, int n)
{
	if(n == 0)
	{
	        return a;
	}
	else
	{
		return gcd(n, a % n);
	}
}
void extendedeuclid(int value1,int value2)
{
	int x = 0, y = 1;  
	int prevx = 1, prevy = 0;  
	while (value2 != 0) 
	{  
         int holdValue = value2;   
		int quotient = value1 / value2;  
        value2 = value1 % value2;  
		value1 = holdValue;  
         holdValue = x;  
         x = prevx - quotient * x;  
         prevx = holdValue;  
         holdValue = y;  
         y = prevy - quotient * y;  
         prevy = holdValue;  

     }  
    cout << "X: " << prevx << " Y:" << prevy << endl;  
    cout << "D:" << value1 << endl; 
}
int modularlinear(int a,int b,int n)
{
	int i;
	int x0;
	int result;
	(d,x,y)= extendedeuclid(a,n);
	if (d/b)
	{
		x0=x*(b/d)%n;
		for(i=0;i<d;i++)
		{
			result=(x0+i*(n/d))%n;
			cout<<result;
		}	
		cout<<"No solution"<<endl;
	}

}
	
unsigned mod_pow(unsigned num, unsigned pow, unsigned mod) 
{ 
    unsigned test; 
    for(test = 1; pow; pow >>= 1) 
    { 
        if (pow & 1) 
            test = (test * num) % mod; 
        num = (num * num) % mod; 
    } 
 
    return test; 
 
} 

int main()
{
     int a,b,n;
	 int m,e,n2;

     //ofstream outf("f://output.txt",ios::out); 
     cout << "Input first number: ";
	 //outf<< "Input first number: ";
     cin >> a;
	 //outf << a<<endl;
     cout << "Input second number: ";
	 //outf<<"Input second number: ";
     cin >> n;
	//outf<< n<<endl;
	 cout<<"b:"<<endl;
	 cin>>b;
	 cout<<"m: "<<endl;
	 cin>>m;
	 cout<<"e: "<<endl;
	 cin>>e;
	 cout<<"n : "<<endl;
	 cin>>n2;
	 cout<<"Number of solutions:"<<modularlinear(a,b,n);
	 cout<<"M^e (mod n) = "<<mod_pow(m,e,n2)<<endl;
     extendedeuclid(a,n);
 
     cout << "GCD ("<<a<<","<<n<<")="<< gcd(a,n) << endl;
	 //outf<<"GCD ("<<a<<","<<n<<")="<< gcd(a,n) << endl;
	
     system("pause");
	 return 0;
}


the error i get is:
f:\rsacrypto\rsacrypto\functions.cpp(42): error C2440: 'initializing' : cannot convert from 'void' to 'int'

I know i have to change one of the functions and id preferably like to not lose my extendedeuclid since it does work.If anyone can assist,id appreciate it.Please be kind to since programming is not my strong suit.
f:\rsacrypto\rsacrypto\functions.cpp(42): error C2440: 'initializing' : cannot convert from 'void' to 'int'
that is because 'extendedeuclid' does not return anything hence void. the expression on line 42 before '=' isn't valid at all
Topic archived. No new replies allowed.