473,378 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

this error"too many arguments to function"

11
I am trying to compile bubble sort program and i get a error message back. "In function ... too many arguments to function. What does this mean?
can you give me the soultion

...
#include<iostream>
using namespace std;
void swap ( int A[]);

int main()
{
int n,i,j;
int A[4];
int temp;
cout<<"please,enter size of element in array";
cin>>n;
cout<<"please,enter numbers of elements in array";
cin>>A[i];

for(i=n-1;i>=1;i--)
{
for(j=0;j<=i-1;j++)
{
if(A[j]>A[j+1])
swap(A,j);
{

temp=A[j];
A[j]=A[j+1];
A[j+1]=temp;
}
}
}
cout<<"element befor sorte are:";
{
else
cout<<"element after sort are:";

system("pause");
}
Attached Files
File Type: txt temp.txt (930 Bytes, 349 views)
Feb 20 '15 #1

✓ answered by weaknessforcats

Your function prototype says swap has one argument:

Expand|Select|Wrap|Line Numbers
  1. void swap ( int A[]);
  2.  
But when you call it, you use two arguments:

Expand|Select|Wrap|Line Numbers
  1. swap(A,j);
  2.  

3 2862
weaknessforcats
9,208 Expert Mod 8TB
Your function prototype says swap has one argument:

Expand|Select|Wrap|Line Numbers
  1. void swap ( int A[]);
  2.  
But when you call it, you use two arguments:

Expand|Select|Wrap|Line Numbers
  1. swap(A,j);
  2.  
Feb 20 '15 #2
xtoma
11
Expand|Select|Wrap|Line Numbers
  1. if(A[j]>A[j+1])
  2.              swap(A);
  3.              {  
  4.                        temp=A[j];
  5.                        A[j]=A[j+1];
  6.                        A[j+1]=temp;
  7.                        }
  8.                        }
  9.                        }
  10.                        cout<<"element befor sorte are:"<<endl;
  11. else
  12.                        cout<<"element after sort are:"<<endl;
  13.                        system("pause");
  14.                        }
  15.  
but
here another problem expected primary-expression before "else"
Feb 20 '15 #3
donbock
2,426 Expert 2GB
It is hard to tell because the braces in your excerpt don't match up.

Proper if-then-else format is
Expand|Select|Wrap|Line Numbers
  1. if (condition)
  2.     statement;
  3. else
  4.     statement;
Either of those statements can be a compound statement:
Expand|Select|Wrap|Line Numbers
  1. {
  2. statement;
  3. ...
  4. statement;
  5. }
It looks like you have more than one statement between the if and the else.
Feb 20 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Edward Diener | last post by:
In the tutorial on functions there are sections on default arguments and keyword arguments, yet I don't see the syntactic difference between them. For default arguments the tutorial shows: def...
9
by: Matt Eberts | last post by:
Sorry, bad title. Anyway, is there a way to pass the arguments to an object instantiated via a constructor using the arguments object and have it expanded, so to speak, so that it doesn't appear as...
1
by: CroDude | last post by:
Hi all! Please help me with this, I'm stuck here. I have a command line .exe file which needs a few arguments passed to do it's job. In help there's a example like this: ...
41
by: Telmo Costa | last post by:
Hi. I have the following code: -------------------------------------- function Tunnel() { //arguments(???); } function Sum() { var sum = 0; for (i=0; i<arguments.length; i++) sum +=...
9
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script...
7
by: sfeher | last post by:
Hi All, Is there a way to preserve the arguments across functions? I have: <script> function myFirstFunction() { // arguments = 'param1'
3
by: pkirk25 | last post by:
// get the item, profession and its mats int get_bill_of_materials(map<string, string&mats_map); map<string, stringcrafted_items; int z = get_bill_of_materials(crafted_items); Have I passed...
36
by: Pacific Fox | last post by:
Hi all, haven't posted to this group before, but got an issue I can't work out... and hoping to get some help here ;-) I've got a base object that works fine with named arguments when called...
12
by: -Lost | last post by:
What in the world is functionName.name good for? That is: function functionName() { return functionName.name; } I mean, I already had to write out the function's name so it seems that it is...
11
by: Daniel T. | last post by:
The function below does exactly what I want it to (there is a main to test it as well.) However, I'm curious about ideas of making it better. Anyone interested in critiquing it? void formatText(...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.