Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

compiling errors

Posted on 2003-10-25
3
Medium Priority
?
256 Views
Last Modified: 2013-12-14
here is my code, I'm getting 3 errors and can't seem to figure out what is causing them, I'm using Visual Studio .NET as the compiler.

GCD.cpp(28) : error C2144: syntax error : 'int' should be preceded by ')'
GCD.cpp(28) : error C2660: 'computegcd' : function does not take 0 parameters
GCD.cpp(28) : error C2059: syntax error : ')'

#include <iostream>
#include <fstream>
using namespace std;

int computegcd (int m, int n);

main()

{
      int r, n, m;
      int count =1;
      int mtemp, ntemp;
      int gcd;
      ifstream infile;
      ofstream outfile;
      infile.open("datafile.dat");
      outfile.open("gcdlist.dat");
 
      while (infile)
      {
            //outfile << "Enter first integer ";
            infile >> m;
            outfile << "\nThe first integer is: " << m << endl;
            //outfile << "Enter second integer ";
            infile >> n;
            outfile << "The second integer is: " << n << endl;
            
this is line 28      gcd = computegcd (int m, int n);

            outfile << "\nThe GCD is: " << gcd << endl;
            outfile << "\n";
            outfile << "\n";
            }
      

infile.close();
outfile.close();
return 0;

}

int computegcd (int m, int n)
{
      int r, ntemp, mtemp;
      if (m < n)
      {
            ntemp = n;
            mtemp = m;
            m = ntemp;
            n = mtemp;
      }
      
            r = n % m;
            while(r != 0)
      {
            n = m;
            m = r;
            r = n % m;
      }

      return m;

}

thanks for the help
0
Comment
Question by:Orlando15767
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 500 total points
ID: 9620707
You don't put types in function calls, only in the function declaration/definition.  Change:
gcd = computegcd (int m, int n);
To:
gcd = computegcd (m, n);

Good luck.
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 9620714
By the way, you can simplify your swap in computegcd to:
if(m < n)
{
  int temp = n;
  n = m;
  m = temp;
}

There's also a swap function in the STL that would do this like:
swap(m, n);

Hope this helps.
0
 
LVL 1

Author Comment

by:Orlando15767
ID: 9620733
works like a charm now, thanks for the help..
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question