Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
exam ata
// Online C compiler to run C program online #include <stdio.h> float getSum(float a, float b); int main(void) { int opt = 0; while ( opt >= 0 ) { printf("A VOID USER-DEFINED FUNCTION FOR:\n"); printf("OPTION 1: Addition\n"); printf("OPTION 2: Subtraction\n"); printf("OPTION 3: Division\n"); printf("OPTION 4: Multiplication\n"); printf("OPTION 5: Power\n"); printf("OPTION 0: End Program\n\n\n"); printf("Input the case number for your operation: "); scanf("%d", &opt); // OPTION 6: End program // printf("Enter option again. Press 0 to return, Press -1 to end\n"); if ( opt == 0 ) { break; } else if ( opt == 1 ) { int addOpt = opt; while ( addOpt > 0 ) { float a, b, sum; printf("Enter a first value: "); scanf("%f", &a); printf("\nEnter a second value: "); scanf("%f", &b); sum = getSum(a, b); printf("\nSum is: %f\n", sum); printf("Would you like to return to the main menu?\n"); printf("Input 0 to return, Input -1 to end: "); scanf("%d", &addOpt); printf("\n"); if ( addOpt == 0 ) { printf("Loading Main...\n"); break; } else if ( addOpt == -1 ) { addOpt = opt; printf("\n"); } } } } return 0; } float getSum(float a, float b) { float result; result = a + b; return result; }
run
|
edit
|
history
|
help
0
FOP utilities
Attractive Numbers
Array_with_join_function
objetos
Lol
hashes
121JHgZzG4QMkDQwLJCifHAAsZAwvpqACY
Basics
Perl Lang
Perlday1