Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Simple Function Creation | Introduction
C++ Functions

book
Simple Function Creation

Uppgift

Swipe to start coding

Your task is to create a function and call this function in the main() function:

  • Create function signature:
    • specify std::string return type;
    • specify helloWorld as the name of the function
  • Return string "Hello World".
  • Call the function using its name.

Lösning

cpp

solution

#include <iostream>

std::string helloWorld()
{
return "Hello World!";
}

int main()
{
std::cout << helloWorld();
}

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 3
#include <iostream>

___ ___()
{
___ "Hello World!";
}

int main()
{
std::cout << ___();
}

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt