Thread: Resistor in Series with parallel Branches

  1. #1
    Registered User
    Join Date
    May 2017
    Posts
    1

    Resistor in Series with parallel Branches

    Hello everybody,I am having difficulties with my final exam.I did mostly everything and the code is working but my professor never taught us how to seperate to branches and do seperate calculation for each branch,can anyone please help me It is very important for me .I would also like to send 10$ on paypal for anyone who can do it for me ,thanks.

    Question:The present quiz is concerned with making calculations on the circuit shown below which consists of:i) an ideal battery with user-supplied terminal voltage V0; andii) a user-supplied number m of branches of resistors which are connected in series within eachbranch, with these branches connected in parallel across each other, and with each branchconsisting of a variable user-supplied number n of resistors and user-supplied values of theresistors. NOTE: the number of resistors in a branch and their values, which are user supplied,vary in general from branch to branch.Design two programs in C, one using the method of call by value and the other using the method of callby reference, which will perform the following computations:i) the equivalent resistance R«t seen by the battery, andii) the one-dimensional array whose elements are the currents Io, Ii, ..., Im-i in the m branches.SAMPLE OUTPUT:For sample output, use the following values for the circuit elements:m=3 (three resistor branches)R[01[0]=10.0, R[0][l]=14.5, RI0)[2]=25.5, R[0][3]=50.0 (no=4, i.e., 4 resistors)R [ l ] [ 0 ] = 2 0 . 0 , R [ l ] [ l ] = 5 0 . 5 , R [ l ] [ 2 ] = 2 9 . 5 ( m = 3 , i . e . , 3 r e s i s t o r s )R [ 2 J [ 0 ) = 1 5 . 4 , R [ 2 ] [ 1 J = 3 4 . 6 ( n 2 = 2 , i . e . , 2 r e s i s t o r s )
    Vo=25




    MY CODE:
    Code:
    #include<stdio.h>
    #define size 100
    void current(float V,float Requiv,int num);
    void voltage(float V,float *RPtr,float Requiv,int num);
    void power (float Ve,float *RPtr,float Requiv,int num);
    
    void series(float *RPtr,float V,int num){
    int i;
    float Gequiv=0,Requiv;
    
    for(i=0;i<num;i++){
    
    
    Gequiv = Gequiv+*(RPtr+i);
    }
    Requiv = Gequiv;
    printf("\nEquivalent resistance is = %.2f K\n",Requiv);
    printf("\n");
    current(V,Requiv,num);
    voltage(V,RPtr,Requiv,num);
    }
    
    void current(float V,float Requiv,int num){
    
    float I;
    
    I =V/Requiv;
    
    
    printf("\nCurrent is = %.2f mA\n",I);
    printf("\n");
    }
    
    
    
    int main(){
    int i,num;
    float R[size];
    float Ve;
    float *RPtr;
    RPtr = R;
    
    printf("Enter the VB Voltage V[%d]: ",i);
    scanf_s("%f",&Ve);
    
    printf("Enter the number of resistors connected in series across the battery: ");
    scanf_s("%d",&num);
    
    for (i=0;i<num;i++){
    printf("Enter the value of resistor R[%d]: ",i);
    scanf_s("%f",&R[i]);
    
    
    }
    printf("\nResistor values in the array: K\n");
    for(i=0;i<num;i++){
    printf("R[%d]=%.2f ",i,R[i]);
    }
    
    series(R,Ve,num);
    
    return 0;
    }
    
    void voltage(float Ve,float *RPtr,float Requiv,int num){
    
    int i;
    float V[size];
    float *vPtr;
    vPtr = V;
    
    for(i=0;i<num;i++){
    
    
    
    V[i] = (Ve**(RPtr+i))/Requiv;
    printf("\nV[%d]= %.2f V\n",i,V[i]);
    printf("\n");
    }
    power(Ve,V,Requiv,num);
    
    
    }
    
    void power (float Ve,float *vPtr, float Requiv ,int num){
    int i;
    float I,p[size],sum,Power;
    I = Ve / Requiv;
    printf("\nThe Power across each resistors are : \n\n");
    sum = 0 ;
    for (i=0;i<=num;i++){
    p[i]= I**(vPtr + i);
    printf("p[%d] = %.2f mwatt\n\n",i,p[i]);
    sum = sum + p[i];
    }
    
    printf("The total power dissipated in the resistors = %.2f m watt \n", sum );
    Power = Ve*I;
    printf("The power supplied by the battery = %.2f m watt\n", sum );
    printf("The power supplied by the battery = %.2f m watt\n",Power);
    printf("--------------------The law of power conversation satisfied--------------------");
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    It looks like you just took the code from here -> I Wrote The Code Above But It Needs To Be Done But... | Chegg.com
    and are now trying to fool your prof as if it were your own work.

    > It is very important for me .I would also like to send 10$ on paypal for anyone who can do it for me ,thanks.
    Are you going to offer up 10% of all your future salary for anyone who can help?

    What's important to me is that people who deserve to fail (lack of effort, knowledge or skill) actually fail, and don't end up polluting the workforce.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Optimization issues - minimize branches
    By std10093 in forum Tech Board
    Replies: 26
    Last Post: 05-13-2013, 03:42 PM
  2. Resistor Color Decoder for a 6 band resistor
    By nivoca in forum C Programming
    Replies: 2
    Last Post: 06-25-2011, 12:44 PM
  3. How to count Branches
    By husslela2 in forum C Programming
    Replies: 35
    Last Post: 04-28-2010, 12:33 AM
  4. Series and Parallel Circuit Calculator
    By LOBH in forum C Programming
    Replies: 1
    Last Post: 11-22-2009, 01:06 PM

Tags for this Thread