0
How to use display somthing on screen in int function without returning the value
c++
7 odpowiedzi
+ 1
#include <iostream>
using namespace std;
int display (int m )
{
cout<< m<<endl;
}
int main ()
{
display (10);
return 0;
}
output is 
10 
+ 1
write cout statement within the function
+ 1
You need to write return statement or call function directly not through cout
0
if i do tjis compiler shows thai it must have a return statement
0
write void display(int m) instead of int display(int m)
0
and if  i try to write void and then 
int main ()
{
cout<<functin name(parameters);
return 0;}
this statement also don't work
0
Hey, 
you cant print the value of m from main function , its illegal and not valid .
We must use return for getting the value from function 
Here the code is 
#include <iostream>
using namespace std;
int display (int m )
{
return m*2;
}
int main ()
{
cout << display (10);
return 0;
}
output is 
20



