Erle Robotics C++ GitBook

Exercises: Functions

Exercise 1

Write a program that calculates 6^5. Declare your own function to do this.

Solution

Exercise 2

Write a program that asks a name say hello. Use your own function, that recives a string of characters (name) and prints on screen the hello message. (Doesn't returns anything- void type)

Solution

Exercise 3

Write a program that ask for two numbers, compare them and show the maximun.Declare a function called max_twothat compares the numbers and returns the maximun.

Solution

Exercise 4

Write a program that asks the user for an integer number and find the sum of all natural numbers upto that number.

Solution