Failing to use parentheses in function calls void of parameters can result in co
ID: 3845212 • Letter: F
Question
Failing to use parentheses in function calls void of parameters can result in compile or invalid program operations. Variable scope identifies any determines the life span of any variable in any programming language. When a variable loses it loses its data value. Local variable are defined in functions, such as main(), and lose their scope each time the functions is executed. Locally scoped variables can be reused in other functions without harming one anothers contents. Global variables are created and defined outside any function, including the main() function. Write a function prototype for the following components:A function that divides two numbers and returns the remainder A function that finds the larger of two numbers and returns the result A function that prints an ATM menu t receives no parameters and returns no value Build the function definitions for each preceding function prototype. Add your own trivia categories to the Trivia game. Modify the Trivia game to track the number of times a user gets an answer correct and When the user quits the program, display the number of correct and incorrect answers. Consider using global variables to track the number of questions answered, the number answered correctly, and the number answered incorrectly.Explanation / Answer
2. i. Definition of a function which returns the remainder when we divide two numbers
int calculate_rem(int a, int b){
int rem= a%b ;
return rem;
}
ii. Function definition which return maximum of two numbers:
int max_of_two(int a, int b){
int max;
if(a>b)
max=a;
else
max=b;
return max;
}
iii. Function definition for ATM menu:
void display_menu(){
int choice;
printf("********Welcome to ATM Service************** ");
printf("1. Check Balance ");
printf("2. Withdraw Cash ");
printf("3. Deposit Cash ");
printf("4. Quit ");
printf("******************?**************************?* ");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice)
{
case 1:
printf(" YOUR BALANCE IN Rs : XXX ");
break;
case 2:
printf(" ENTER THE AMOUNT TO WITHDRAW: ");
}
break;
case 3:
printf(" ENTER THE AMOUNT TO DEPOSIT");
break;
case 4:
printf(" THANK U USING ATM");
break;
default:
printf(" INVALID CHOICE");
}
}
For each case, we can customize to perform the operation as we want.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.