0

How to use display somthing on screen in int function without returning the value

c++

16th Dec 2016, 3:26 PM
ADIL KAKAKHEL
ADIL KAKAKHEL - avatar
7 Respostas
+ 1
#include <iostream> using namespace std; int display (int m ) { cout<< m<<endl; } int main () { display (10); return 0; } output is 10
16th Dec 2016, 4:59 PM
Mock
Mock - avatar
+ 1
write cout statement within the function
16th Dec 2016, 4:59 PM
Vijeth Belle
Vijeth Belle - avatar
+ 1
You need to write return statement or call function directly not through cout
16th Dec 2016, 5:06 PM
Vijeth Belle
Vijeth Belle - avatar
0
if i do tjis compiler shows thai it must have a return statement
16th Dec 2016, 5:00 PM
ADIL KAKAKHEL
ADIL KAKAKHEL - avatar
0
write void display(int m) instead of int display(int m)
16th Dec 2016, 5:02 PM
Vijeth Belle
Vijeth Belle - avatar
0
and if i try to write void and then int main () { cout<<functin name(parameters); return 0;} this statement also don't work
16th Dec 2016, 5:04 PM
ADIL KAKAKHEL
ADIL KAKAKHEL - avatar
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
16th Dec 2016, 5:13 PM
Mock
Mock - avatar