Write a program that displays the resistance equivalent to three resistors R1, R2, R3 (double type),

  • if the resistors are connected in series: $$R_{ser} = R1+R2+R3$$
  • if the resistors are connected in parallel: $$R_{par} =\frac{R1*R2*R3}{R1*R2+R1*R3+R2*R3}$$

Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>

int main()
{
    double R1, R2, R3;
    
    printf("Please enter the values of 3 resistors: ");
    scanf("%lf %lf %lf", &R1, &R2, &R3);
    
    printf("Equivalent resistance in series = %lf\n" , R1 + R2 + R3);
    
    printf("Equivalent resistance in parallel = %lf\n" , (R1 * R2 * R3) / (R1*R2 + R1*R3 + R2*R3));
    
    return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Variable static implementation of a queue - version 2