I am trying to write a program that asks for two integers and then finds the greatest common factor between them. IN C++
Can anyone fix this? Just copy paste the fix program.
PLZ don’t tell me what to do because I can't fallow way you say.
Thank you
.............................
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
#include %26lt;math.h%26gt;
#include %26lt;iostream%26gt;
using namespace std;
int factor(int a, int b);
int main()
{
int x, y;
cout %26lt;%26lt; "This program allows calculating the factor\n";
cout %26lt;%26lt; "Value 1: ";
cin %26gt;%26gt; x;
cout %26lt;%26lt; "Value 2: ";
cin %26gt;%26gt; y;
cout %26lt;%26lt; "\nThe Greatest Common factor of "
%26lt;%26lt; x %26lt;%26lt; " and " %26lt;%26lt; y %26lt;%26lt; " is " %26lt;%26lt; factor(x, y) %26lt;%26lt; endl;
return 0;
}
int factor(int a, int b)
{
int ret_val=0;
/* CASE 1 a %26gt; b */
if (a %26gt; b)
{
ret_val = a/b;
}
else /* CASE 2 b %26gt;= a */
{
ret_val = b/a;
}
return (ret_val);
}
}
}
}
Programing help plzzzz?
very good
Reply:Try :
#include %26lt;iostream.h%26gt;
Note that the ".h" is missing from your code.
Reply:Ok. I won't tell you what you should do to fix it.
No, I am not going to just "paste and fix" it for you.
Anything else you would like me to not say or do?
You seem pretty bossy for someone looking for help. I imagine you would be a real joy to work with : )
Reply:the problem that u have pasted a c++ program in to a .NET program "C# or VB.NET"
this is the program in C++
#include %26lt;math.h%26gt;
#include %26lt;iostream%26gt;
using namespace std;
int factor(int a, int b);
int main()
{
int x, y;
cout %26lt;%26lt; "This program allows calculating the factor\n";
cout %26lt;%26lt; "Value 1: ";
cin %26gt;%26gt; x;
cout %26lt;%26lt; "Value 2: ";
cin %26gt;%26gt; y;
cout %26lt;%26lt; "\nThe Greatest Common factor of "
%26lt;%26lt; x %26lt;%26lt; " and " %26lt;%26lt; y %26lt;%26lt; " is " %26lt;%26lt; factor(x, y) %26lt;%26lt; endl;
return 0;
}
int factor(int a, int b)
{
int ret_val=0;
/* CASE 1 a %26gt; b */
if (a %26gt; b)
{
ret_val = a/b;
}
else /* CASE 2 b %26gt;= a */
{
ret_val = b/a;
}
return (ret_val);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment