My program couldn’t run. How to tell program that the smallest resistance value is series?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

My program couldn’t run. How to tell program that the smallest resistance value is series??

#include <stdio.h> int main(){ int r[5],num,i,parallel_rs=0; int equiv_resistance; int min_element; printf("Enter number of resistances: ");// must be 3 values and above scanf("%d", &num); while (1) { scanf("%d", &r[i]); if (r[i] == 0) //Assuming that all values are greater than zero break; //and input is terminated by a 0 as flag value if (r[i] < min_element) min_element = r[i]; i++; } if (i < 3) { while (i < 3) { printf("please enter a value\n"); //keep requesting the values from the user until we get scanf("%d", &r[i]); //atleast three values if (r[i] < min_element) min_element = r[i]; i++; } printf("\nEnter value of each resistance:"); for (i=0;i<num;i++){ printf("\nR%d: ",i+1); scanf("%d",&r[i]); } for (i=0;i<num;i++){ parallel_rs+=(1/r[i]);//parallel calc equiv_resistance += 1 / parallel_rs;//series calc return equiv_resistance; printf("\nEquivalent series resistance: %d Ohms", parallel_rs); } return 0; } } I am new

9th Dec 2020, 2:59 PM
Elliot
0 Answers