Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A. Define a struct in C with tag Capacitor that holds the following information

ID: 3766566 • Letter: A

Question

A. Define a struct in C with tag Capacitor that holds the following information about a capacitor:
Model number (e.g. 11-123U), capacitance (e.g. 1000 uf), voltage (e.g. 2.5 V), cost ($6.50)

Create your main program file capacitorsInfo.c. Declare two variables of type struct Capacitor and populate them with the following values:
First variable: model is 11-123U, capacitance is 100, voltage is 25 and cost is $6.00

Second variable: model is 65T91a, capacitance is 22000, voltage is 20 and cost is $25.00

Print the model number of the first capacitor and the voltage of the second.

B.

Add a third Capacitor variable and initialize it from values entered by the user.

Declare an array of Capacitors of size 4 and copy the three capacitors you created to the array.
Populate the fourth element of the array from user input.

C.

Add a function displayCapacitorInfo that takes a capacitor as input parameter and prints its details in the following format:

Capacitor 11-123U:
* Capacitance 100 uF

* Voltage: 25 V

* Cost: $25.00

Call your function on all members of the array.

Explanation / Answer

#include<stdio.h>
#include<conio.h>
struct Capacitor
   {
       char Model_num[10];
       int capacitance;
       float voltage;
       float cost;
   };
void displayCapacitorInfo(struct Capacitor c)
{
   printf("Capacitor: %s",c.Model_num);
   printf("Capacitance: %d",c.capacitance);
   printf("voltage: %f",c.voltage);
   printf("Cost: %s",c.cost);
}

void main()
{

   struct Capacitor a,b;
   struct Capacitor c;
   strcpy(a.Model_num,"11-123U");
   a.capacitance=100;
   a.voltage=25;
   a.cost=6.00;

   strcpy(b.Model_num,"65T91a");
   b.capacitance=22000;
   b.voltage=20;
   b.cost=25.00;

   printf("Model number=%s",a.Model_num);
   printf("Voltage =%f",b.voltage);

   printf("Enter Model number");
   scanf("%s",&c.Model_num);

   printf("Enter Capacitance");
   scanf("%d",&c.capacitance);

   printf("Enter Voltage:");
   scanf("%s",&c.voltage);

   printf("Enter Cost:");
   scanf("%s",&c.cost);

   displayCapacitorInfo(b);
   getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote