Thread: Resistance Calculator , my resistor values are wrong at the end for calculation2&3

  1. #1
    Registered User
    Join Date
    Feb 2020
    Posts
    2

    Resistance Calculator , my resistor values are wrong at the end for calculation2&3

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    int main()
    
    
    
    
    
    
    {
        char c1, c2, c3, c4, c5, c6, choicenew;
        int choiceRs;
        float RsP,Rs3,Rs2,Rs1,choiceSP3,choiceSP2,choiceSP1,choiceSP=0,choiceRs3,choiceRs2,choiceRs1,rone3,rone2,rone1,rtwo3,rtwo2,rtwo1,rthree3,rthree2,rthree1;
        printf("-----------------------------------------------------------------------------------------------------------------------\n");
        printf("Project Done By:123\nProject Title: Resistance Calculator\n");
        printf("-----------------------------------------------------------------------------------------------------------------------\n");
        start:
        printf("Enter 6 secret Number(PASSWORD): \n");
        c1 = getch(); putchar('*');
        c2 = getch(); putchar('*');
        c3 = getch(); putchar('*');
        c4 = getch(); putchar('*');
        c5 = getch(); putchar('*');
        c6 = getch(); putchar('*');
    
    
                 if (c1 == '1' && c2 == '2' && c3 == '3' && c4 == '4' && c5 == '5' && c6 == '6')
            {
                printf("\nWelcome to Equivalent Resistance Calculator!!! \n");
    
    
                printf("\nYou're advised to Calculate 3 times for proper Summary\n");
            }
            else
            {
              printf("\n You have entered wrong Password!\n");
              goto start;
    
    
    
    
            }
            /* printf("\nSshhh!! Secret letters you typed are: %c%c%c%c%c%C", c1, c2, c3, c4, c5, c6);*/
    
    
    
    
    
    
    
    
    select:
             printf("\nSelect Either Series or Parallel Circuit\n");
             printf("\nPress 1 for Series Circuit \nPress 2 for Parallel Circuit\n ");
    
    
     {
    
    
            int choiceSP, i;
            float r[3] , RsS = 0;
            start2:
            scanf("%d",&choiceSP);
    
    
            choiceSP3=choiceSP2;
            choiceSP2=choiceSP1;
            choiceSP1=choiceSP;
    
    
    
    
    switch (choiceSP)
    
    
    {
    case 1 :
            printf("You have chosen *Series Circuit* ");
    
    
    {
             printf("\nEnter the number of Resistors in your circuit:\n ");
             printf("\nPress 1 for 2 Resistors \nPress 2 for 3 Resistors \n ");
    
    
                     int choiceRs;
                     start3:
                     scanf("%d",&choiceRs);
    
    
                     choiceRs3=choiceRs2;
                     choiceRs2=choiceRs1;
                     choiceRs1=choiceRs;
    
    
    
    
    switch (choiceRs)
    
    
                    {
                    case 1 :
                      printf("\nYou have chosen *2 Resistors*");
    {
                      {
    
    
                        printf("\nEnter Value of Each Resistor (in Ohm) : \n");
    
    
                        for (i = 0; i < 2; i++)
                          {
                            printf("\nR%d : ", i + 1);
                            scanf("%f", &r[i]);
                           rone3=rone2;
                           rone2=rone1;
                           rone1=r[0];
                           rtwo3=rtwo2;
                           rtwo2=rtwo1;
                           rtwo1=r[1];
                           rthree3=rthree2;
                           rthree2=rthree1;
                           rthree1=r[2];
                          }
    
    
                        for (i = 0; i < 2; i++)
                        {
                        RsS = RsS + r[i];
                        }
    
    
                        printf("\nEquivalent Series Resistance = %.4f Ohm", RsS);
    
    
                                                                    Rs3=Rs2;
                                                                    Rs2=Rs1;
                                                                    Rs1=RsS;
                        getch();
                        system("CLS");
    YN1 :
    {
           printf("\nDo you want to calculate a new one?\n");
           printf("\nPress Y for *Yes* and N for *No* (End Program after showing summary)\n");
           fflush(stdin);
           scanf("%c", &choicenew);
    
    
           system("CLS");
      {
    
    
    
    
           if (choicenew == 'Y' || choicenew == 'y')
               {
                goto select;
               }
           else if (choicenew == 'N' || choicenew == 'n')
               {
                goto summary;
                break;
               }
           else if (choicenew != 'Y' || choicenew != 'y' || choicenew != 'N' || choicenew != 'n')
               {
                printf("Please choose either Y or N");
                goto YN1;
               }
    
    
      }
    
    
    }
                          }
                         break;
    
    
    
    
                        case 2 :
                        printf("\nYou have chosen *3 Resistors*");
                        {
                        {
                             printf("\nEnter Value of Each Resistor (in Ohm)  : \n");
    
    
                             for (i = 0; i < 3; i++)
                           {
                            printf("\nR%d : ", i + 1);
                            scanf("%f", &r[i]);
    
    
                          rone3=rone2;
                           rone2=rone1;
                           rone1=r[0];
                           rtwo3=rtwo2;
                           rtwo2=rtwo1;
                           rtwo1=r[1];
                           rthree3=rthree2;
                           rthree2=rthree1;
                           rthree1=r[2];
    
    
                           }
                           for (i = 0; i < 3; i++)
                           {
                           RsS = RsS + r[i];
                           }
    
    
                        printf("\nEquivalent Series Resistance = %.4f Ohm", RsS);
    
    
                                                                          Rs3=Rs2;
                                                                          Rs2=Rs1;
                                                                          Rs1=RsS;
    
    
                        getch();
                        system("CLS");
    
    
    YN2 :
     {
          printf("\nDo you want to calculate a new one?\n");
          printf("\nPress Y for *Yes* and *N* for No (End Program after showing summary) \n");
          fflush(stdin);
          scanf("%c", &choicenew);
          system("CLS");
          if (choicenew == 'Y' || choicenew == 'y')
             {
              goto select;
             }
          else if (choicenew == 'N' || choicenew == 'n')
             {
              goto summary;
              break;
             }
          else
             {
              printf("Please choose either Y or N");
              goto YN2;
             }
    
    
     }
    
    
                            }
                                }
    
    
    break;
    default:
    printf("Sorry you are only allowed to choose either 2 or 3 resistors\n");
    
    
    goto start3;
    break;
    
    
    }
    
    
                                }
                                break;
    case 2 :
                   printf("You have chosen *Parallel Circuit*");
                   float RsP = 0, invRsP = 0;
                {
                  printf("\nEnter the number of Resistors in your circuit:\n ");
                  printf("\nPress 1 for 2 Resistors \nPress 2 for 3 Resistors \n ");
    
    
                    int choiceRs;
                    start4:
                    scanf("%d",&choiceRs);
                     choiceRs3=choiceRs2;
                     choiceRs2=choiceRs1;
                     choiceRs1=choiceRs;
    
    
    switch (choiceRs)
    
    
    
    
    
    
    {
        case 1 :
        printf("\nYou have chosen *2 Resistors*");
        /*float r[10];*/
    
    
     {
         {
         printf("\nEnter Value of Each Resistor (in Ohm)  : n");
         for (i = 0; i < 2; i++)
         {
         printf("\n R%d : ", i + 1);
         scanf("%f", &r[i]);
           rone3=rone2;
                           rone2=rone1;
                           rone1=r[0];
                           rtwo3=rtwo2;
                           rtwo2=rtwo1;
                           rtwo1=r[1];
                           rthree3=rthree2;
                           rthree2=rthree1;
                           rthree1=r[2];
         }
         for (i = 0; i < 2; i++)
         {
         invRsP+=(1.0/r[i]);
         }
         RsP=(1.0/invRsP);
         }
    
    
         printf("\nEquivalent Parallel Resistance = %.4f Ohm", RsP);
    
    
                                                            Rs3=Rs2;
                                                            Rs2=Rs1;
                                                            Rs1=RsP;
    
    
           getch();
           system("CLS");
    YN3:
    {
    
    
    
    
        printf("\nDo you want to calculate a new one?\n");
        printf("\nPress Y for *Yes* and N for *No* (End Program after showing summary)\n");
        fflush(stdin);
        scanf("%c", &choicenew);
        system("CLS");
        if (choicenew == 'Y' || choicenew == 'y')
        {
         goto select;
        }
        else if (choicenew == 'N' || choicenew == 'n')
        {
         goto summary;
         break;
        }
        else
         {
           printf("Please choose either Y or N");
           goto YN3;
         }
    }
    }
    break;
                case 2 :
                  printf("\nYou have chosen *3 Resistors*");
    {
            {
                 printf("\nEnter Value of Each Resistor (in Ohm) : \n");
                 for (i = 0; i < 3; i++)
                {
                 printf("\n R%d : ", i + 1);
                 scanf("%f", &r[i]);
    
    
                 rone3=rone2;
                           rone2=rone1;
                           rone1=r[0];
                           rtwo3=rtwo2;
                           rtwo2=rtwo1;
                           rtwo1=r[1];
                           rthree3=rthree2;
                           rthree2=rthree1;
                           rthree1=r[2];
                }
                for (i = 0; i < 3; i++)
                {
                 invRsP+=(1.0/r[i]);
                }
                RsP=(1.0/invRsP);
            }
    
    
            printf("\nEquivalent Parallel Resistance = %.4f Ohm", RsP);
    
    
                                                                Rs3=Rs2;
                                                                Rs2=Rs1;
                                                                Rs1=RsP;
                getch();
                system("CLS");
    YN4:
    {
           printf("Do you want to calculate a new one?");
           printf("\nPress Y for *Yes* and N for *No* (End Program after showing summary)\n");
           fflush(stdin);
           scanf("%c", &choicenew);
           system("CLS");
           if (choicenew == 'Y' || choicenew == 'y')
          {
          goto select;
          }
          else if (choicenew == 'N' || choicenew == 'n')
          {
           goto summary;
           break;
          }
          else
          {
           printf("Please choose either Y or N");
           goto YN4;
          }
    
    
    }
    }
    
    
           break;
    default:
    printf("Sorry you are only allowed to choose either 2 or 3 resistors\n");
    goto start4;
    break;
    
    
    }
    }
           default:
           printf("Sorry please choose either 1 or 2 \n");
           goto start2;
           break;
    }
    
    
    summary:
    
    
        system("COLOR CF");
    
    
        printf("---------------------------------------------------------------------------------------------------------------------");
        printf("\nTake Note :");
        printf("\n\nCircuit type:\n1 = Series Circuit &\n2 = Parallel Circuit\n\n");
        printf("\nCalculation 1 is the latest while Calculation 3 was the earliest");
        printf("\n---------------------------------------------------------------------------------------------------------------------\n");
    
    
        printf("\nCalculation 1 : Equivalent Resistance = %.4f Ohm You chose Circuit type %.f  and %.f Resistors  \nR1=%.f, R2=%.f, R3=%.f\n",Rs1,choiceSP1,choiceRs1 + 1, rone1, rtwo1, rthree1);
        printf("\nCalculation 2 : Equivalent Resistance = %.4f Ohm You chose Circuit type %.f  and %.f Resistors  \nR1=%.f, R2=%.f, R3=%.f\n",Rs2,choiceSP2,choiceRs2 + 1, rone2, rtwo2, rthree2);
        printf("\nCalculation 3 : Equivalent Resistance = %.4f Ohm You chose Circuit type %.f  and %.f Resistors  \nR1=%.f, R2=%.f, R3=%.f\n",Rs3,choiceSP3,choiceRs3 + 1, rone3, rtwo3, rthree3);
        printf("\n*********************************************************************************************************************\n");
    
    
        printf("                                                THANK YOU!!!!                                                            ");
    
    
        printf("*********************************************************************************************************************");
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    }
    } }
    Last edited by PsychoBandit; 02-10-2020 at 07:59 AM.

  2. #2
    Registered User
    Join Date
    Feb 2020
    Posts
    2
    Resistance Calculator , my resistor values are wrong at the end for calculation2&amp;3-error-jpg

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well your first problem is that you have a main() which is poorly formatted, 100's of lines long AND riddled with goto's.
    Whoever's been responsible for your programming education up to now has been doing a very bad job.

    The whole of each case for series and parallel circuits should be separate functions.

    In both cases, the 2 resistor case is just a special case of the 3 resistor case.
    By suitable initialisation of the 3rd resistor value, you can prune away an awful lot of copy/paste code.

    There are a whole bunch of variables which may be uninitialised.
    Code:
    $ gcc -Wall -Wextra -Wno-unused-result -O2 foo.c
    foo.c: In function ‘main’:
    foo.c:15:8: warning: implicit declaration of function ‘getch’ [-Wimplicit-function-declaration]
       c1 = getch();
            ^
    foo.c:8:62: warning: unused variable ‘choiceSP’ [-Wunused-variable]
       float RsP, Rs3, Rs2, Rs1, choiceSP3, choiceSP2, choiceSP1, choiceSP =
                                                                  ^
    foo.c:8:9: warning: unused variable ‘RsP’ [-Wunused-variable]
       float RsP, Rs3, Rs2, Rs1, choiceSP3, choiceSP2, choiceSP1, choiceSP =
             ^
    foo.c:7:7: warning: unused variable ‘choiceRs’ [-Wunused-variable]
       int choiceRs;
           ^
    foo.c:293:7: warning: ‘rthree2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:296:7: warning: ‘rthree1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:293:7: warning: ‘rtwo2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:296:7: warning: ‘rtwo1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:293:7: warning: ‘rone2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:296:7: warning: ‘rone1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:298:38: warning: ‘choiceRs2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                Rs3, choiceSP3, choiceRs3 + 1, rone3, rtwo3, rthree3);
                                          ^
    foo.c:295:38: warning: ‘choiceRs1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
                Rs2, choiceSP2, choiceRs2 + 1, rone2, rtwo2, rthree2);
                                          ^
    foo.c:293:7: warning: ‘choiceSP1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:296:7: warning: ‘choiceSP2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:293:7: warning: ‘Rs1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    foo.c:296:7: warning: ‘Rs2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           printf
           ^
    But because the code is such a rats-nest, there's no point in trying to trace through it all just to check.


    Finally, some indentation.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    int main()
    {
      char c1, c2, c3, c4, c5, c6, choicenew;
      int choiceRs;
      float RsP, Rs3, Rs2, Rs1, choiceSP3, choiceSP2, choiceSP1, choiceSP =
          0, choiceRs3, choiceRs2, choiceRs1, rone3, rone2, rone1, rtwo3, rtwo2, rtwo1, rthree3, rthree2, rthree1;
      printf("-------------------------------------------------------------------\n");
      printf("Project Done By:123\nProject Title: Resistance Calculator\n");
      printf("-------------------------------------------------------------------\n");
    start:
      printf("Enter 6 secret Number(PASSWORD): \n");
      c1 = getch();
      putchar('*');
      c2 = getch();
      putchar('*');
      c3 = getch();
      putchar('*');
      c4 = getch();
      putchar('*');
      c5 = getch();
      putchar('*');
      c6 = getch();
      putchar('*');
      if (c1 == '1' && c2 == '2' && c3 == '3' && c4 == '4' && c5 == '5' && c6 == '6') {
        printf("\nWelcome to Equivalent Resistance Calculator!!! \n");
        printf("\nYou're advised to Calculate 3 times for proper Summary\n");
      } else {
        printf("\n You have entered wrong Password!\n");
        goto start;
      }
      /* printf("\nSshhh!! Secret letters you typed are: %c%c%c%c%c%C", c1, c2, c3, c4, c5, c6); */
    select:
      printf("\nSelect Either Series or Parallel Circuit\n");
      printf("\nPress 1 for Series Circuit \nPress 2 for Parallel Circuit\n ");
      {
        int choiceSP, i;
        float r[3], RsS = 0;
      start2:
        scanf("%d", &choiceSP);
        choiceSP3 = choiceSP2;
        choiceSP2 = choiceSP1;
        choiceSP1 = choiceSP;
        switch (choiceSP) {
        case 1:
          printf("You have chosen *Series Circuit* ");
          {
            printf("\nEnter the number of Resistors in your circuit:\n ");
            printf("\nPress 1 for 2 Resistors \nPress 2 for 3 Resistors \n ");
            int choiceRs;
          start3:
            scanf("%d", &choiceRs);
            choiceRs3 = choiceRs2;
            choiceRs2 = choiceRs1;
            choiceRs1 = choiceRs;
            switch (choiceRs) {
            case 1:
              printf("\nYou have chosen *2 Resistors*");
              {
                {
                  printf("\nEnter Value of Each Resistor (in Ohm) : \n");
                  for (i = 0; i < 2; i++) {
                    printf("\nR%d : ", i + 1);
                    scanf("%f", &r[i]);
                    rone3 = rone2;
                    rone2 = rone1;
                    rone1 = r[0];
                    rtwo3 = rtwo2;
                    rtwo2 = rtwo1;
                    rtwo1 = r[1];
                    rthree3 = rthree2;
                    rthree2 = rthree1;
                    rthree1 = r[2];
                  }
                  for (i = 0; i < 2; i++) {
                    RsS = RsS + r[i];
                  }
                  printf("\nEquivalent Series Resistance = %.4f Ohm", RsS);
                  Rs3 = Rs2;
                  Rs2 = Rs1;
                  Rs1 = RsS;
                  getch();
                  system("CLS");
                YN1:
                  {
                    printf("\nDo you want to calculate a new one?\n");
                    printf("\nPress Y for *Yes* and N for *No* (End Program after showing summary)\n");
                    fflush(stdin);
                    scanf("%c", &choicenew);
                    system("CLS");
                    {
                      if (choicenew == 'Y' || choicenew == 'y') {
                        goto select;
                      } else if (choicenew == 'N' || choicenew == 'n') {
                        goto summary;
                        break;
                      } else if (choicenew != 'Y' || choicenew != 'y' || choicenew != 'N' || choicenew != 'n') {
                        printf("Please choose either Y or N");
                        goto YN1;
                      }
                    }
                  }
                }
                break;
            case 2:
                printf("\nYou have chosen *3 Resistors*");
                {
                  {
                    printf("\nEnter Value of Each Resistor (in Ohm)  : \n");
                    for (i = 0; i < 3; i++) {
                      printf("\nR%d : ", i + 1);
                      scanf("%f", &r[i]);
                      rone3 = rone2;
                      rone2 = rone1;
                      rone1 = r[0];
                      rtwo3 = rtwo2;
                      rtwo2 = rtwo1;
                      rtwo1 = r[1];
                      rthree3 = rthree2;
                      rthree2 = rthree1;
                      rthree1 = r[2];
                    }
                    for (i = 0; i < 3; i++) {
                      RsS = RsS + r[i];
                    }
                    printf("\nEquivalent Series Resistance = %.4f Ohm", RsS);
                    Rs3 = Rs2;
                    Rs2 = Rs1;
                    Rs1 = RsS;
                    getch();
                    system("CLS");
                  YN2:
                    {
                      printf("\nDo you want to calculate a new one?\n");
                      printf("\nPress Y for *Yes* and *N* for No (End Program after showing summary) \n");
                      fflush(stdin);
                      scanf("%c", &choicenew);
                      system("CLS");
                      if (choicenew == 'Y' || choicenew == 'y') {
                        goto select;
                      } else if (choicenew == 'N' || choicenew == 'n') {
                        goto summary;
                        break;
                      } else {
                        printf("Please choose either Y or N");
                        goto YN2;
                      }
                    }
                  }
                }
                break;
            default:
                printf("Sorry you are only allowed to choose either 2 or 3 resistors\n");
                goto start3;
                break;
              }
            }
            break;
        case 2:
            printf("You have chosen *Parallel Circuit*");
            float RsP = 0, invRsP = 0;
            {
              printf("\nEnter the number of Resistors in your circuit:\n ");
              printf("\nPress 1 for 2 Resistors \nPress 2 for 3 Resistors \n ");
              int choiceRs;
            start4:
              scanf("%d", &choiceRs);
              choiceRs3 = choiceRs2;
              choiceRs2 = choiceRs1;
              choiceRs1 = choiceRs;
              switch (choiceRs)
              {
              case 1:
                printf("\nYou have chosen *2 Resistors*");
                /*float r[10]; */
                {
                  {
                    printf("\nEnter Value of Each Resistor (in Ohm)  : n");
                    for (i = 0; i < 2; i++) {
                      printf("\n R%d : ", i + 1);
                      scanf("%f", &r[i]);
                      rone3 = rone2;
                      rone2 = rone1;
                      rone1 = r[0];
                      rtwo3 = rtwo2;
                      rtwo2 = rtwo1;
                      rtwo1 = r[1];
                      rthree3 = rthree2;
                      rthree2 = rthree1;
                      rthree1 = r[2];
                    }
                    for (i = 0; i < 2; i++) {
                      invRsP += (1.0 / r[i]);
                    }
                    RsP = (1.0 / invRsP);
                  }
                  printf("\nEquivalent Parallel Resistance = %.4f Ohm", RsP);
                  Rs3 = Rs2;
                  Rs2 = Rs1;
                  Rs1 = RsP;
                  getch();
                  system("CLS");
                YN3:
                  {
                    printf("\nDo you want to calculate a new one?\n");
                    printf("\nPress Y for *Yes* and N for *No* (End Program after showing summary)\n");
                    fflush(stdin);
                    scanf("%c", &choicenew);
                    system("CLS");
                    if (choicenew == 'Y' || choicenew == 'y') {
                      goto select;
                    } else if (choicenew == 'N' || choicenew == 'n') {
                      goto summary;
                      break;
                    } else {
                      printf("Please choose either Y or N");
                      goto YN3;
                    }
                  }
                }
                break;
              case 2:
                printf("\nYou have chosen *3 Resistors*");
                {
                  {
                    printf("\nEnter Value of Each Resistor (in Ohm) : \n");
                    for (i = 0; i < 3; i++) {
                      printf("\n R%d : ", i + 1);
                      scanf("%f", &r[i]);
                      rone3 = rone2;
                      rone2 = rone1;
                      rone1 = r[0];
                      rtwo3 = rtwo2;
                      rtwo2 = rtwo1;
                      rtwo1 = r[1];
                      rthree3 = rthree2;
                      rthree2 = rthree1;
                      rthree1 = r[2];
                    }
                    for (i = 0; i < 3; i++) {
                      invRsP += (1.0 / r[i]);
                    }
                    RsP = (1.0 / invRsP);
                  }
                  printf("\nEquivalent Parallel Resistance = %.4f Ohm", RsP);
                  Rs3 = Rs2;
                  Rs2 = Rs1;
                  Rs1 = RsP;
                  getch();
                  system("CLS");
                YN4:
                  {
                    printf("Do you want to calculate a new one?");
                    printf("\nPress Y for *Yes* and N for *No* (End Program after showing summary)\n");
                    fflush(stdin);
                    scanf("%c", &choicenew);
                    system("CLS");
                    if (choicenew == 'Y' || choicenew == 'y') {
                      goto select;
                    } else if (choicenew == 'N' || choicenew == 'n') {
                      goto summary;
                      break;
                    } else {
                      printf("Please choose either Y or N");
                      goto YN4;
                    }
                  }
                }
                break;
              default:
                printf("Sorry you are only allowed to choose either 2 or 3 resistors\n");
                goto start4;
                break;
              }
            }
        default:
            printf("Sorry please choose either 1 or 2 \n");
            goto start2;
            break;
          }
        summary:
          system("COLOR CF");
          printf("------------------------------------------------------");
          printf("\nTake Note :");
          printf("\n\nCircuit type:\n1 = Series Circuit &\n2 = Parallel Circuit\n\n");
          printf("\nCalculation 1 is the latest while Calculation 3 was the earliest");
          printf("\n------------------------------------------------------------\n");
          printf
              ("\nCalculation 1 : Equivalent Resistance = %.4f Ohm You chose Circuit type %.f  and %.f Resistors  \nR1=%.f, R2=%.f, R3=%.f\n",
               Rs1, choiceSP1, choiceRs1 + 1, rone1, rtwo1, rthree1);
          printf
              ("\nCalculation 2 : Equivalent Resistance = %.4f Ohm You chose Circuit type %.f  and %.f Resistors  \nR1=%.f, R2=%.f, R3=%.f\n",
               Rs2, choiceSP2, choiceRs2 + 1, rone2, rtwo2, rthree2);
          printf
              ("\nCalculation 3 : Equivalent Resistance = %.4f Ohm You chose Circuit type %.f  and %.f Resistors  \nR1=%.f, R2=%.f, R3=%.f\n",
               Rs3, choiceSP3, choiceRs3 + 1, rone3, rtwo3, rthree3);
          printf("\n**************************************************************\n");
          printf("                                           THANK YOU!!!!             ");
          printf("************************************************************");
        }
      }
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Dec 2017
    Posts
    1,632
    You need to learn to:
    * properly indent your code;
    * stop using goto (use while and for instead)
    * use arrays
    * use functions
    * don't flush(stdin)
    A little inaccuracy saves tons of explanation. - H.H. Munro

  5. #5
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Well, PsychoBandit was polite enough to respond 10 hours ago here : c - I have error in showing the entered Resistor Values at the summary (last part of program) - Stack Overflow

    but haven't seen them here since 13 hours ago so I guess they've solved their problem. Now it just needs to be submitted and marked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My calculator in Dividing seems wrong I think
    By YaZao in forum C Programming
    Replies: 3
    Last Post: 07-27-2015, 08:09 PM
  2. Help! Calculator Not Working...What is wrong?
    By usernamed in forum C++ Programming
    Replies: 7
    Last Post: 08-08-2013, 10:52 PM
  3. write() and read() int values from socket returning wrong values.
    By Premjith P S in forum Linux Programming
    Replies: 8
    Last Post: 11-29-2012, 02:59 PM
  4. Resistor Color Decoder for a 6 band resistor
    By nivoca in forum C Programming
    Replies: 2
    Last Post: 06-25-2011, 12:44 PM
  5. What's wrong with my calculator?
    By andrewmin in forum C Programming
    Replies: 3
    Last Post: 09-08-2010, 02:30 PM

Tags for this Thread