0
Please tell me how to remove error
#include <iostream> using namespace std; void func(int x,int y) { int z; z=x+y; return z;} int main() { return 0; }
7 Respostas
+ 8
first of all your function is of void type and u r trying to return a value "z" and another thing is that it is not called in main function.
so either make the function of int type and then call it to main method.
#include <iostream>
using namespace std;
int func(int x,int y)
{
int z;
z=x+y;
return z;}
int main() {
cout<<func(4,5);
return 0;
}
OR
let your function be of void type and pass the argument from the main method and don't return any value.. print the value of "z" directly in "func()" function.
#include <iostream>
using namespace std;
void func(int x,int y)
{
int z;
z=x+y;
cout<<z;}
int main() {
func(4,5);
return 0;
}
+ 3
I don't understand, you have made more complex codes than this. Why can 't you fix it yourself.
+ 1
@ Anuj kumar
In line 3,
You have to declare constant at last, it is necessary to declare variables first in function parameters
Solved: int func(int n, int m = 10){
0
thanks everyone
0
#include <iostream>
using namespace std;
int func(int m=10,int n){
int c;
c=m+n;
return c;
}
int main() {
cout<<func(5);
return 0;
}
and how solve this ?
0
how to solve ?