Design a program in C,using the method of call by reference, which will compute
ID: 1811801 • Letter: D
Question
Design a program in C,using the method of call by reference, which will compute the equivalent resistance REQ to the M resistors R[0],R[1],R[2]...,R[M-1] , connected in series where the number M of resistors is user-supplied. The resistors R[0],R[1],R[2]...,R[M-1] are actually equivalent resistors to R[0]=R[00] || R[01] || R[02] ||...|| R[0(No-1)].
+R[0] is the equivalent resistance to No resistors R[00],R[01],R[02],....,R[0(No-1) connected in parallel ,where the number No is user-supplied and the resistor values R[00],R[01],R[02],....,R[0(No-1) are all user-supplied. Similarlly, for instance R[3]=R[30] || R[31] || R[32] ||...|| R[3(N3-1)]. R[3] is the equivalent resistance to N3 resistors R[30],R[31],R[32],... R[3(N3-1)] connected in parallel,where the number N3 is user supplied and the resistors values R[30],R[31],R[32],..R[3(N3-1)] are all user supplied.
Explanation / Answer
#include<stdio.h>
void series(int *reg,int m,int n);
void main()
{
int reg[10][10],i,j,m,n;
printf("enter the number of register in series and parallel");
scanf("%d %d",&m,&n);
printf("enter value of reg ");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",®[i][j]);
}
series(reg,m,n);
}
void series(int *reg,int m ,int n)
{
int a[m];
for(int i=0;i<m;i++) // for parallel connection
{
a[i]=0;
for(int j=0;j<n;j++)
{
a[i]=a[i]*reg[i][j]/(a[i]+reg[i][j];
}
}
int sum =0;
for(i=0;i<m;i++)
sum=sum+a[i];
printf("the equivalent resistance is %d",sum);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.