Can this please be done in C programming without any Arrays --------------------
ID: 3888110 • Letter: C
Question
Can this please be done in C programming without any Arrays
--------------------------------------------------------------------------------------
We are going to create a simple resistance calculator.
ask the user if the resistors are in series or parallel
read in the number of resistors
read in the resistance of the individual resistors (let's assume they are all the same resistance) by having the user enter the first three colors of the 4 bands on the resistor (this site can help with color code calculations) https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-resistor-color-code-4-band
calculate the total resistance of the circuit (this site can help with parallel resistor equations calculatons) http://www.daycounter.com/Calculators/Parallel-Resistance-Calculator.phtml
print out the result
Below is a sample execution of the program (values in bold are user input and should NOT be hardcoded into your program)
Are the resistors in Series or Parallel? Series
How many resistors are there in the circuit? 5
The first three color bands on the resistors: Red Red Red
Each resistor is 2200 ohms and the total resistance of the circuit is 11000 ohms
Would you like to perform another calculation (Y/N)? Y
Are the resistors in Series or Parallel? Parallel
How many resistors are there in the circuit? 4
The first three color bands on the resistors: Red Red Red
Each resistor is 2200 ohms and the total resistance of the circuit is 550 ohms
Would you like to perform another calculation (Y/N)? N
Extra Credit:
1) Format the output so it's more appealing (not so many 0's and uses appropriate suffixes K,M,G, etc)
2) Handle invalid gracefully, if expecting a number and user gives a letter, or expecting a letter and get a number, or get wrong number of inputs, etc.
Explanation / Answer
Note:
As you hav already the working code.Just Am writing here the snippet of code you require.If you want me any modifications.Just ask me.Thank You.
_____________________
#include <stdio.h>
#include <math.h>
int main()
{
char ch;
while(1)
{
//Here yiou have to paste your logic here.Then the loop repeats until you press other than 'y' or 'Y'
//like printf("Ask the resistor in series or parallel ?" );
printf(" Do you Want to continue(Y/N):");
scanf(" %c",&ch);
if(ch=='y'||ch=='Y')
{
continue;
}else
{
break;
}
}
return 0;
}
___________________Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.