Question: I'm receiving an error when I try to compile my code. Can I get some help? Error and code below! -------------------------------------------------------------------------------------------------------- #include using namespace std;

I'm receiving an error when I try to compile my code. Can I get some help? Error and code below!

I'm receiving an error when I try to compile my code. Can

--------------------------------------------------------------------------------------------------------

#include

using namespace std;

int GCD(int a,int b);

int main(){

/**

* Below two integer variables are declared named a and b.

*/

int a,b;

/**

* Below we prompt user to enter both values of a and b.

*/

cout

cin>>a>>b;

/**

* Below we call the function GCD of type int and pass the values a and b.

* Whatever the function returns, we store it in integer variable named answer.

*/

int answer=GCD(a,b);

/**

* Below we print the Output in required format.

*/

cout

return 0;

}

int GCD(int a,int b){

/**

* The function to calculate the Greatest Common Divisor, is actually

* the Euclid's GCD algorithm.

* It uses recursive approach to calculate the GCD.

*/

if(b==0){

/**

* Once the b parameter is 0 then we return first parameter as GCD.

*/

return a;

}else{

/**

* If both are not 0 then we Call GCD function recursively by passing

* b as first parameter

* and remainder of division a by b i.e a%b as second parameter.

*/

return GCD(b,a%b);

}

}

/tmp/ccLDzqlw.o: In function main' assignment1.cc:(.text+0x11): undefined reference to std: :cout' assignmentl.cc:(.text+0x16): undefined reference to std: :basic_ostream >& std::operator >(std::basic ostre am >&, char const*)' assignment1.cc:(.text+0x22): undefined reference to std::cin' assignmentl.cc:(.text+0x27): undefined reference to std: :basic_istream >::operator>>(int&)' assignmentl.cc:(.text+0x36): undefined reference to std: :basic_istream >::operator>>(int&)' assignmentl.cc:(.text+0x59): undefined reference to std: :cout' assignmentl.cc:(.text+0x5e): undefined reference to std: :basic_ostream >& std::operator >(std::basic ostre am >&, char const*)' assignmentl.cc:(.text+0x69): undefined reference to std: :basic_ostream >: :operator >& std::operator >(std::basic ostre am >&, char const*)' assignmentl.cc:(.text+0x80): undefined reference to std: :basic_ostream >: :operator >& std::operator >(std::basic ostre am >&, char const*)' assignmentl.cc:(.text+0x9a): undefined reference to std: :basic_ostream >: :operator >& std::endl >(std::basic ostrea m >&)' assignmentl.cc:(.text+0xa7): undefined reference to std: :basic_ostream >:operator >& () (std::basicostream >&))' /tmp/ccLDz q1w.o: In function -static-initialization-and-destruction-0(int, int) assignmentl.cc:(.text+0x10e) undefined reference to std::ios_base: Init::Init) assignment1.cc:(.text+0x113): undefined reference to std::ios_base: :Init::-Init( /tmp/ccLDzq1w. o:(.eh frame+0x12): undefined reference to gxx personality v0' collect2: ld returned 1 exit status

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!