online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
''' Demo code for functions, parameters, return statements, and variable scope -Dr. G 9/21/2021 Note : if it is easier for you, copy the instructions and place them in a separate file ''' #############DEMO INSTRUCTIONS############# #From now on we are going to structure our code using a main function #1. Take the below hello world program and restructure the file into: #imports, functions, and main #Restructure the code to have a main function #This is the way you need to do your code from this point forward #What is a main function and what does it signify? #2. Create a function that prints whatever you send it # "Sent Value : " # test this function #3. Now send it three things and retest #4. Create a function that computes and prints the distance between two points # given x1, y1, x2, y2 # the formula for that is d = ((x2 - x1)**2 + (y2 - y1)**2) **0.5 #5. Modify this function to store the value in a variable called result and try # to access that variable in main. #What's going on? #What's the program stack? #6. Create a constant variable with enclosing scope like : PI = 3.14159 #What is a "constant?" #What is the convention for a constant? #Why are enclosing non-constant variables bad? #What does the global modifier do? #7. Place this constant and the functions in another file and rewrite the code to #access them #8. Demonstrate the three different ways to imports #import #import "" as "" #from "" import "" #9. CS is often like a puzzle #Challenge : create a function in your function file that accepts three numbers #have it return the highest of those three numbers. #test it with at least 5 cases ''' Tip: result = num1 "conditionals" return result ''' #############IMPORTS############### #############FUNCTIONS############# #############MAIN################## #Beginning of control flow printMe("Woot", 42, 5.89)

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue