Ask Question
17 June, 08:59

Write a function named get_my_age that returns your age as an int (this is YOUR age, so if you were 21 you would return the number 21). Note that this function takes no arguments and no input from the user. Call the function once and print the result. Reflect on the difference between creating a variable with a constant value and creating a function with no arguments that returns a constant return value.

+1
Answers (1)
  1. 17 June, 10:52
    0
    The programming language is not stated; However, I'll answer this question using 2 programming languages (Python and C++)

    Comments are used for explanatory purpose

    Python program starts here

    def get_my_age () : #Declare function

    age = 21 #Assign value to age

    print (age) #Print age

    get_my_age () #Call function

    #End of Program

    C+ + Programming Language starts here

    #include

    using namespace std;

    int get_my_age () / /Declare Function

    {

    int age = 21; / /Assign value to age

    cout<
    }

    int main ()

    {

    get_my_age (); / /Call Function

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a function named get_my_age that returns your age as an int (this is YOUR age, so if you were 21 you would return the number 21). ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers