online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
''' Demo code for module 1 "Getting user input and Selection" 9/15/2021 -Dr. G It's time to learn how to interact with the user and create more than one pathway within your code. ''' #Concept 1 Getting user input ''' #Where does it go? input("Plese enter something : ") ''' ''' #We got to do something with it #Run this multiple times with different types var = input("Plese enter something : ") print(var) print(type(var)) #What did you learn? #What am I doing here? #var = int(input("Plese enter a number from 1 - 5 : ")) #print(type(var)) ''' #Concept 2 Multiple execution paths #Draw the following as a flow chart ''' if (True): print("True") if (False): print("False") ''' #ICE 2 ''' Put some of the concepts together. Take the previous ICE and make it so you can enter side 1 and side 2 If the user enters a negative number, make that number 1 instead Briefly draw this out as a flow chart. ''' #Let's make it more complicated. Remember boolean operators #var = int(input("Plese enter a number from 1 - 5 : ")) #check to see if the number is between 1 - 5 in one statement #Concept 2 multiple paths ''' #Two path option and nesting x=4 y=5 if(x>y): print("x is bigger") else: print("y is bigger") print("Woot") #What if they are the same value? Draw this and then Fix this. ''' ''' #elif #Why is the below code inefficent? #Fix it with else then reduce that to elifs var = int(input("Please enter a number from 1 - 12 : ")) if (var == 1): print("Jan") if (var == 2): print("Feb") if (var == 3): print("Mar") if (var == 4): print("Apr") if (var == 5): print("May") if (var == 6): print("Jun") if (var == 7): print("Jul") if (var == 8): print("Aug") if (var == 9): print("Sept") if (var == 10): print("Oct") if (var == 11): print("Nov") if (var == 12): print("Dec") if(var > 12): print("Invalid Input") if(var < 1): print("Invalid Input") ''' #ICE final ''' Adapt your following code by accepting side 1 and side 2, but then printing a menu: Enter 1 to calculate a triangle hypotenuse Enter 2 to calculate the area of a rectangle Enter 3 for divisable by (print if the 1st number is divisable by the 2nd) Save their answer in a variable called selection Print the correct results depending on what the user selects If something other than 1,2, or 3 is entered print an error message instead Draw this out as a flowchart '''

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