Friday, November 21, 2014

C Combination program



To find equivalent capacitance of Parallel combination of capacitive circuit

#include
#include 
int main()
{
   float c[10], num, Cp = 0;
   int i;
   clrscr();
   printf("Enter the number of Capacitors : ");
   scanf("%f", &num);
   printf("\nEnter Value of Each Capacitor : n");
   for (i = 0; i < num; i++)
   {
      printf("\nC%d : ", i + 1);
      scanf("%f", &c[i]);
   }
   for (i = 0; i < num; i++)
   {
      Cp = Cp + c[i];
   }
   printf("\nEquivalent Parallel Capacitance : %f mFarad", Cp);
   return (0);
}

Output

Enter the number of Capacitors : 3
Enter Value of Each Capacitor :
C1 : 1.2
C2 : 1.3
C3 : 1.4
Equivalent Parallel Capacitance : 3.900000 mFarad

C Program to Find equivalent capacitance of series combination of capacitive circuit

#include
#include 
 int main()
{
   float c[10], num, Cs = 0;
   int i;
   clrscr();
   printf("Enter the number of Capacitors : ");
   scanf("%f", &num);
   printf("\nEnter Value of Each Capacitor : n");
   for (i = 0; i < num; i++)
   {
      printf("\nC%d : ", i + 1);
      scanf("%f", &c[i]);
   }
    for (i = 0; i < num; i++)
   {
      Cs = Cs + (1.0 / c[i]);
   }
   Cs = 1.0 / Cs;
   printf("\nEquivalent Series Capacitance : %f mFarad", Cs);
   return (0);
}

Output

Enter the number of Capacitors : 3
Enter Value of Each Capacitor :
C1 : 1
C2 : 1
C3 : 1
Equivalent Series Capacitance : 0.333333 mFarad

C Program to Find equivalent resistance of Parallel combination of resistive circuits

#include
#include
int main()
{
   int r[10], num, i, Rs = 0;
   printf("Enter the number of Resistances : ");
   scanf("%d", &num);
   printf("\nEnter Value of Each Resistance : n");
   for (i = 0; i < num; i++)
   {
      printf("\n R%d : ", i + 1);
      scanf("%d", &r[i]);
   }
   for (i = 0; i < num; i++)
   {
      Rs = Rs + r[i];
   }
    printf("\nEquivalent Series Resistance : %d Kohm", Rs);
   return (0);
}

Output

Enter the number of Resistances : 3
Enter Value of Each Resistance :
R1 : 4
R2 : 2
R3 : 3
Equivalent Parallel Resistance : 0.923077 Kohm

To find equivalent resistance of series combination of resistive circuits

#include
#include
int main()
{
    int r[10], num, i, Rs = 0;
    printf("Enter the number of Resistances : ");
    scanf("%d", &num);
    printf("\nEnter Value of Each Resistance : n");
    for (i = 0; i < num; i++)
    {
        printf("\nR%d : ", i + 1);
        scanf("%d", &r[i]);
    }
     for (i = 0; i < num; i++)
    {
        Rs = Rs + r[i];
    }
    printf("\nEquivalent Series Resistance : %d Kohm", Rs);
    return (0);
}

Output

Enter the number of Resistances : 5
Enter Value of Each Resistance :
R1 : 3
R2 : 2
R3 : 3
R4 : 2
R5 : 1

Equivalent Series Resistance : 11 Kohm

To find equivalent capacitance of Parallel combination of capacitive circuit

#include
#include
 int main()
{
   float c[10], num, Cp = 0;
   int i;
   clrscr();
   printf("Enter the number of Capacitors : ");
   scanf("%f", &num); 
   printf("\nEnter Value of Each Capacitor : n");
   for (i = 0; i < num; i++)
  {
      printf("\nC%d : ", i + 1);
      scanf("%f", &c[i]);
   }
    for (i = 0; i < num; i++)
   {
      Cp = Cp + c[i];
   }
   printf("\nEquivalent Parallel Capacitance : %f mFarad", Cp);
   return (0);
}

Output

Enter the number of Capacitors : 3
Enter Value of Each Capacitor :
C1 : 1.2
C2 : 1.3
C3 : 1.4
Equivalent Parallel Capacitance : 3.900000 mFarad

No comments:

Post a Comment