Question

Need the c code please, also please only use <stdio.h> library. Simple code please

Define a struct with teg Capacitor that holds the

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#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();
}

Add a comment
Know the answer?
Add Answer to:
Need the c code please, also please only use <stdio.h> library. Simple code please Define a...
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
  • Java Code please read comments and add the code to required lines....LINE 1 to LINE 5...

    Java Code please read comments and add the code to required lines....LINE 1 to LINE 5 ********************************************************************** * Program Summary: This program demonstrates these basic Java concepts: * - Creating an array based on user input * - Accessing and displaying elements of the array * * The program should declare an array to hold 10 integers. * The program should then ask the user for an integer. * The program should populate the array by assigning the user-input integer...

  • Lanuage C++ (Beginner level) Please...I need help with this assignment If I still have question, can...

    Lanuage C++ (Beginner level) Please...I need help with this assignment If I still have question, can i contact you? -------------------------- Program 1 - WRITE ALL THE CODE in ONE FILE...   MyArrayPtrArith1.cpp Step 1 - Define the class Write a class, myArrayClass, that creates an integer array. * Add an 'arraySize' variable, initialize to zero ( default constructor function ) * Create int * ptrArray ( default constructor set to NULL ) * Add a default constructor ( see above for...

  • Please answer using C ++ programming language ONLY! We have only used <stdio.h> if that helps....

    Please answer using C ++ programming language ONLY! We have only used <stdio.h> if that helps. This is a basic course and the furthest we have gone is BASIC arrays. Write the code for the following problems using arrays. Write what would go in the “int main()” part of the program. For these problems, the entire program and program output is not needed. Just include what goes in the int main() part of the program. 1. Declare an integer array...

  • Please do in C and only use stdio.h. Write a program that reads n integers into...

    Please do in C and only use stdio.h. Write a program that reads n integers into an array, then prints on a separate line the value of each distinct element along with the number of times it occurs. The values should be printed in ascending order. Turn in your code and input/result together. Suppose, for example, that you input the values -7 3 3 -7 5 5 3 as the elements of your array. Then your program should print -7...

  • C++ please use only easy code and stdio.h because im just a beginner Description Write the...

    C++ please use only easy code and stdio.h because im just a beginner Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value...

  • Please design, write the code and create the requisite submission files in C++ for the following...

    Please design, write the code and create the requisite submission files in C++ for the following problem: A menu-driven program that offers the user 5 options as follows: Menu: 1. Display array 2. Add up all elements in the array and display that number. 3. Add 1 to each element in the array. 4. Swap the values in row one with the values in row three. 5. Exit In main(), declare and initialize a 2-dimensional array that contains 5 x...

  • Coding in C. Please only use stdio.h (which would mean no malloc or anything like that)...

    Coding in C. Please only use stdio.h (which would mean no malloc or anything like that) (30 pts) Write a sorting program using an array. First read n integers and store them in an array. Then use any sorting algorithm (you can choose any one) to sort these numbers in ascending order. Turn in your code and input/result together. For example, if your input is 10 -9 5 1000 -9 1 20 -100 then your output should be -100 -9...

  • How would I change the following C code to implement the following functions: CODE: #include <stdio.h>...

    How would I change the following C code to implement the following functions: CODE: #include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]) { if (argc != 2) printf("Invalid input!\n"); else { FILE * f = fopen (argv[1], "r"); if (f != NULL) { printf("File opened successfully.\n"); char line[256]; while (fgets(line, sizeof(line), f)) { printf("%s", line); } fclose(f); } else { printf("File cannot be opened!"); } } return 0; } QUESTION: Add a function that uses fscanf like this:...

  • need the code in .c format #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> struct _cplx double re,...

    need the code in .c format #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> struct _cplx double re, im; // the real and imaginary parts of a complex number }; typedef struct _cplx Complex; // Initializes a complex number from two real numbers Complex CmplxInit(double re, double im) Complex z = { re, im }; return z; // Prints a complex number to the screen void CmplxPrint(Complex z) // Not printing a newline allows this to be printed in the middle of...

  • Lab Topics • The basics of Array object Use the following Coding Guidelines • When declaring...

    Lab Topics • The basics of Array object Use the following Coding Guidelines • When declaring a variable, you usually want to initialize it. Remember you cannot initialize a number with a string. Remember variable names are case sensitive. Use tabs or spaces to indent code within blocks (code surrounded by braces). Use white space to make your program more readable. Use comments after the ending brace of classes, methods, and blocks to identify to which block it belongs. Problem...

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
ADVERTISEMENT