Help with function please

Write your question here.
I want it to print the number i input however it only let me input number but it doesn't print out the result
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
int myabs(int val);
int main()
{
int val;
cout << "Input a number ";
cin >> val;
int myabs(val);
}
may I ask, where you print the number out? Because you use cout to print things out, and I dont see a cout after you have taken the input.

int myabs(val); This doesnt do anything.

Doesnt look like you know how functions work. Watch video 9-11.

https://www.youtube.com/playlist?list=PLAE85DE8440AA6B83
You need to define
 
int myabs (int val);

after main. Right now you have declared it but it has no definition and thus does nothing when called.

1
2
3
4
int myabs()
{
      // Put some code here
}
Topic archived. No new replies allowed.