Question

Problem: Design and write a C language program that can be used to calculate Voltage, Current and Total Resistance for a Seri
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<conio.h>
int main()
{
int choice=0;
do
{
clrscr();
printf("\n\tMENU ");
printf("\n\t------------------------------");
printf("\n\n\t 1. SERIES");
printf("\n\t 2. PARALLEL");
printf("\n\t 3. SERIES PARALLEL");
printf("\n\t 4. EXIT");
printf("\n\n Enter Your CHoice: ");
scanf("%1[1234]d%*c",&choice);
switch(choice)
{
case 1:
series();
break;
case 2:
parallel();
break;
case 3:
seriesparallel();
break;
case 4:
  
exit(0);
default:
printf("\nINVALID SELECTION...Please try again");
}
getch();
}while(choice!=4);
}
void series()
{
   reads();
}
  
void reads()
{
   int r[10], num, i,voltage;
printf("Enter the number of Resistances : ");
scanf("%d", &num);
printf("Enter voltage");
scanf("%d",&voltage);

printf("\nEnter Value of Each Resistance : n");
for (i = 0; i < num; i++) {
printf("\n R%d : ", i + 1);
scanf("%d", &r[i]);
}
cals(num,voltage,r);
}  

void cals(int num,int voltage,int r[10])
{
   float cur;
   int i,Rs=0;
   for (i = 0; i < num; i++) {
Rs = Rs + r[i];
}
cur=voltage/Rs;
prints(Rs,cur,r);
}  
  
void prints(int Rs,float cur,int r[10])
{
printf("\nEquivalent Series Resistance : %d Kohm", Rs);
print("\ncurrent = %f",cur);
for (i = 0; i < num; i++) {
printf("\n Voltage across R%d : ", i + 1);
   printf("%d",cur*r[i]);
}

}

void parallel()
{
   readp();
}
  
void readp()
{
int n; /* number of resistors */

int voltage; /* loop variable and voltage */

printf("enter number of resistors\n");
scanf("%d",&n);

printf("Enter voltage");
scanf("%d",&voltage);
calp(n,voltage);
}
  
void calp(int n,int voltage)
{
float temp,cur=0;
   float er; /* equivalent resistance */
int i,r2;
printf("enter all resistances\n ");
scanf("%f",&er);
for(i=1;i<n;i++)
{
scanf("%d",&r2);
temp=(1/er)+((1/(float)r2)); /* cast r2 to float */
er=(1/temp);
}
cur=v/er;
printp(er,cur);
}
  
  
void printp(float er,float cur)
{

printf("\nequivalent resistance = %f",er);
print("\ncurrent = %f",cur);
for (i = 0; i < num; i++) {
printf("\n Voltage across R%d : ", i + 1);
   printf("%d",cur*r[i]);
  
}
}  

  

Add a comment
Know the answer?
Add Answer to:
Problem: Design and write a C language program that can be used to calculate Voltage, Current...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

  • Please, I need help, I cannot figure out how to scan variables in to the function...

    Please, I need help, I cannot figure out how to scan variables in to the function prototypes! ******This is what the program should look like as it runs but I cannot figure out how to successfully build the code to do such.****** My code: #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <conio.h> float computeSeriesResistance(float R1, float R2, float R3); float computeParallelResistance(float R1, float R2, float R3); float computeVoltage(int current, float resistance); void getInputR(float R1, float R2, float R3); void getInputCandR(int...

  • Write a program in C++ to calculate the average (mean) and the standard deviation of a...

    Write a program in C++ to calculate the average (mean) and the standard deviation of a list of numbers using vectors. Your program should... Prompt for the number of values the user wishes to enter Prompt the user to enter the values one at a time for the number of requested values into a vector Calculate and display the Mean and Standard Deviation The flow of your code should be similar to: int main() { /** Prompt the user and...

  • Trying to write this program using c language using functions, pointers and loops. "al 67% 1...

    Trying to write this program using c language using functions, pointers and loops. "al 67% 1 1 :14 AM importanu Name your TIies HW2 firstlastname.c Develop a solution to the following problem: A financial institution will only accept loan applications if the following conditions are met: The applicant must own his/her home with no mortgage payment and -The applicant must have a total annual household income of no less than $45000.00. The applicant must have a credit score of no...

  • Answer using C++ Write a program that will calculate the final sales price of a motorcycle;...

    Answer using C++ Write a program that will calculate the final sales price of a motorcycle; this includes additional optional packages along with sales tax. You may assume that the base? price of the motorcycle is $30,000. First you must ask the user to choose which optional packages they want. The user is only permitted to choose one package. Your program should display a menu of the available packages. The user should enter the package by entering the letter associated...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • INTEL 80x86 ASSEMBLY LANGUAGE CODE Write a windows32 assembly language program that utilizes a recursive procedure....

    INTEL 80x86 ASSEMBLY LANGUAGE CODE Write a windows32 assembly language program that utilizes a recursive procedure. The main (_MainProc) procedure should: accept, from the user, a positive integer. Guard against non-positive integers being entered using a loop. call the sumseries sub-procedure using the cdecl protocol, receive the results of the sub-procedure, and display the results. The sumseries sub-procedure should: recursively find the sum of the series: 1*2 + 2*3 + 3*4 + ... + i*(i+1) (This is an iterative definition....

  • Can you help us!! Thank you! C++ Write a program that can be used by a...

    Can you help us!! Thank you! C++ Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT