Search for question
Question

1. Consider an AC circuit with three resistances in series. The program below computes the current in this circuit, but it has a few bugs. Copy the code into a new Replit, find each bug, correct it, and add a comment explaining what the issue was. Try to get the program to a point where it runs without errors/warnings. #include <stdio.h> float compute_current(float, float, float, float); int main(void) { } float voltage, res1, res2, res3, current; printf("Enter voltage and three resistances: \n") scanf("%f %f %f %f", &voltage, &res1, &res2, &res3); current = compute_current(voltage, res1, res2, res3); printf("Current is: %f\n", current); return 0; float compute_current(voltage, res1, res2, res3) { } float I; I = voltage res1 + res2 + res3; 2. Write a recursive function that computes MN where M is any integer and N is any integer greater than or equal to 0. Your recursive function should have a base condition and a recursive condition. Also, write a main function that calls your recursive function at least once then displays the result using printf. For example, if your function is called my_power_function, and you provide the following input my_power_function(2,3) where M-2 and N=3, then the function should recursively compute 2*2*2 = 8, where the returned value is 8. 3. Repeat the above problem but instead of writing a recursive function, write a non-recursive function that uses looping to solve the problem.

Fig: 1