C++ Function Declaration and Definition Question

Introduction

Write a program that declares and defines a function of type void called printmessage().

The function outputs a "Hello World from a function." message on the standard output.

Call the function from main.

You can use the following code structure.

#include <iostream> 

int main() 
{ 
    //your code here
} 


#include <iostream> 

void printmessage(); // function declaration 

int main() 
{ 
    printmessage(); 
} 

// function definition 
void printmessage() 
{ 
    std::cout << "Hello World from a function."; 
} 



PreviousNext

Related