Question: How do I export my C++ code on Xcode to Scientific Work Place? Is there a code I have to add? My code is written

How do I export my C++ code on Xcode to Scientific Work Place? Is there a code I have to add? My code is written down below.

#include

#include

int gcd(int , int );

using namespace std;

int main()

{

int num1, num2, hcf,prd,lcm;

cout << "Enter two numbers to find GCD using Euclidean algorithm: ";

cin >> num1 >> num2;

hcf = gcd(num1, num2);

if (hcf)

{

prd=num1*num2; // calculating product of 2 numbers

lcm=prd/hcf;

cout << " The GCD of " << num1 << " and " << num2 << " is: " << hcf

<< endl;

cout << " The LCM of " << num1 << " and " << num2 << " is: " << lcm

<< endl;

ofstream out_data("filename.txt"); //openning the file

out_data << " The GCD of " << num1 << " and " << num2 << " is: " << hcf; // writing into the file

out_data << " The LCM of " << num1 << " and " << num2 << " is: " << lcm;

}

else

cout << " Invalid input!!! ";

}

int gcd(int u, int v)

{

return (v != 0) ? gcd(v, u % v) : u;

}

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!