Advertisement
HoussemNa12

Untitled

Nov 29th, 2020
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.70 KB | None | 0 0
  1.  __| |____________________________________________| |__
  2. (__   ____________________________________________   __)
  3.    | |                                            | |
  4.    | |                                            | |
  5.    | |                                            | |
  6.    | |               Excercice 1                  | |
  7.    | |                                            | |
  8.    | |                                            | |
  9.  __| |dc__________________________________________| |__
  10. (__   ____________________________________________   __)
  11.    | |                                            | |
  12.  
  13. #include <stdio.h>
  14.  
  15. #define EN_PARALLELE 1
  16. #define EN_SERIE 0
  17.  
  18. int main() {
  19.     float R1, R2, R3;
  20.     int typeDeMontage;
  21.  
  22.     printf("Donner la valeur de R1 >>:");
  23.     scanf("%f", &R1);
  24.     printf("Donner la valeur de R2 >>:");
  25.     scanf("%f", &R2);
  26.     printf("Donner la valeur de R3 >>:");
  27.     scanf("%f", &R3);
  28.  
  29.     printf("Quel est le type de montage utilise?\n");
  30.     printf("0: Montage en serie\n");
  31.     printf("1: Montage en parallele\n");
  32.  
  33.     do {
  34.         printf(">>:");
  35.         scanf("%d", &typeDeMontage);
  36.     } while (typeDeMontage != 0 && typeDeMontage != 1);
  37.  
  38.     printf("La resistance equivalente est : ");
  39.  
  40.     if (typeDeMontage == EN_SERIE) {
  41.         printf("%.3f", R1 + R2 + R3);
  42.     } else if (typeDeMontage == EN_PARALLELE) {
  43.         printf("%.3f", (R1 * R2 * R3) / (R1 * R2 + R1 * R3 + R2 * R3));
  44.     }
  45.  
  46. }
  47.  
  48.  
  49.  
  50. ---------------------------------------------------------------------------------------
  51. |                                  Exercice 2                                         |
  52. ---------------------------------------------------------------------------------------
  53.  
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement