what is void

I have a question
why do we use such a big program like
// void function example
#include <iostream>
using namespace std;

void printmessage ()
{
cout << "I'm a function!";
}

int main ()
{
printmessage ();
return 0;
}



we could simple do
cout <<"I am a function";

what is the purpose of void ?
void indicates the function has no return type. Also, read through http://www.cplusplus.com/doc/tutorial/functions.html.
I read that ,I didn't get anything
what does it mean the function has no return type ?
It means that the function doesn't have to return a value

eg:
1
2
3
4
5
6
7
8
9
int sum(int a, int b)
{
    return a+b;//returns an int
}
void printmessage ()
{
    cout << "I'm a function!";
    //returns nothing
}
Last edited on
Topic archived. No new replies allowed.