is this a valid way to call function?

Write your question here.

1
2
3
4
5
6
7
8
9
  void sumArray();
void main()
{
	int shahgee[2][2];
	int n[2][2];
	sumArray(shahgee,n);
}
	void sumArray(int mehdi[2][2],int shah[2][2]){
		int sum[2][2];
Please don't spam the forum with the same question multiple times. We're already trying to help you in your other thread.
closed account (jwkNwA7f)
No, when you defined it here:
void sumArray();
You are saying it has no arguments.
Here it has 2 arguments:
8
9
void sumArray(int mehdi[2][2],int shah[2][2]){
		int sum[2][2];

You should do it like this:
1
2
3
4
5
6
7
8
9
  void sumArray(int mehdi[2][2], int shah[2][2]);
void main()
{
	int shahgee[2][2];
	int n[2][2];
	sumArray(shahgee,n);
}
	void sumArray(int mehdi[2][2],int shah[2][2]){
		int sum[2][2];
ok brother.plz tell me.i hav to submit my project tomorw and i am stuck here.just tell me how to call function given below in main?
void main() is not valid. It should always be int main().

You need to declare arguments in your function when you declare it. Take this example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
#include <iostream> 

void MyFunction(int x, int y); //Function arguments must be declared here! 

int main()
{ 
    int n = 44; 
    int i = 94; 
    MyFunction(n,i);
    return 0;
}

void MyFunction(int x, int y)
{
    int z = x * y; 
    std::cout << z << "\n"; 
}
Last edited on
Topic archived. No new replies allowed.