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 current, float resistance);
void myInfo();
void displayMenu();
int main()
{
myInfo();
getInputR();
getInputCandR();
displayMenu();
float R1, R2, R3;
float resistance;
int current;
int choice; //get the choice of the user
scanf("%d", &choice);
while (choice != 4) //exit when user gives 4
{
if (choice == 1)
printf("After Computing Series resistance : %f\n", computeSeriesResistance(R1, R2, R3));
if (choice == 2)
printf("After Computing Parallel resistance : %f\n", computeParallelResistance(R1, R2, R3));
if (choice == 3)
printf("After Computing Volatege : %f\n", computeVoltage(current, resistance));
displayMenu();
scanf("%d", &choice);
}
getchar();
return 0;
}
void getInputR(float R1, float R2, float R3)
{
printf("Enter three resistor values: ");
scanf("%f%f%f", &R1, &R2, &R3);
}
void getInputCandR(int current, float resistance)
{
printf("\n\nEnter a current (whole #) and the resisistance (real #): ");
scanf("%d%f", ¤t, &resistance);
}
float computeSeriesResistance(float R1, float R2, float R3)
{
return R1 + R2 + R3;
}
float computeParallelResistance(float R1, float R2, float R3)
{
float f = (1.0 / R1) + (1.0 / R2) + (1.0 / R3);
printf("%f\n", f);
return 1 / f;
}
float computeVoltage(int current, float resistance)
{
return current*resistance;
}
void myInfo()
{
printf("************************************\n");
printf("*\t\t\t *\n");
printf("*\\t *\n");
printf("*\t\t\t\t *\n");
printf("*\t\t\t *\n");
printf("************************************\n");
}
void displayMenu()
{
printf("Mini Electrical Circuit\n");
printf("--------------------------\n");
printf("--------------------------\n");
printf("1.Equivalant Series Resitance\n");
printf("2.Equivalant Parallel Resitance\n");
printf("3.Ohm's law: V = I * R\n");
printf("4.Exit\n");
}
Made changes to your code. so once check and run.
**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();
void getInputCandR();
void myInfo();
void displayMenu();
float R1, R2, R3;
float resistance;
int current;
int main()
{
myInfo();
getInputR();
getInputCandR();
displayMenu();
int choice; //get the choice of the user
printf("\nEnter your choice : ");
scanf("%d", &choice);
while (choice != 4) //exit when user gives 4
{
if (choice == 1)
printf("After Computing Series resistance : %.2f\n\n", computeSeriesResistance(R1, R2, R3));
if (choice == 2)
printf("After Computing Parallel resistance : %.2f\n\n", computeParallelResistance(R1, R2, R3));
if (choice == 3)
printf("After Computing Volatege : %.2f\n\n", computeVoltage(current, resistance));
displayMenu();
printf("\nEnter your choice : ");
scanf("%d", &choice);
}
getchar();
return 0;
}
void getInputR()
{
printf("Enter three resistor values: ");
scanf("%f %f %f", &R1, &R2, &R3);
}
void getInputCandR()
{
printf("Enter a current (whole #) and the resisistance (real #): ");
scanf("%d %f", ¤t, &resistance);
}
float computeSeriesResistance(float R1, float R2, float R3)
{
return R1 + R2 + R3;
}
float computeParallelResistance(float R1, float R2, float R3)
{
float f = (1.0 / R1) + (1.0 / R2) + (1.0 / R3);
return 1 / f;
}
float computeVoltage(int current, float resistance)
{
return current*resistance;
}
void myInfo()
{
printf("************************************\n");
printf("*\t\t\t *\n");
printf("*\\t *\n");
printf("*\t\t\t\t *\n");
printf("*\t\t\t *\n");
printf("************************************\n");
}
void displayMenu()
{
printf("\nMini Electrical Circuit\n");
printf("--------------------------\n");
printf("--------------------------\n");
printf("1.Equivalant Series Resitance\n");
printf("2.Equivalant Parallel Resitance\n");
printf("3.Ohm's law: V = I * R\n");
printf("4.Exit\n");
}
**Comment for any further queries.
Please, I need help, I cannot figure out how to scan variables in to the function...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...
Complete the functions for the program complex.c (Down) . The program adds, subtracts,and multiplies complex numbers. The C program will prompt the user for the choice of operations,read in the complex numbers, perform the operations, and print the results. The main programrepeatedly prints the menu, reads in the user’s selection, and performs the operation. We use pointers only for those arguments that the function intends to change. In all thefunctions, r represents the real component and i represents the imaginary...
So I have a question in regards to my program. I'm learning to program in C and I was curious about the use of functions. We don't get into them in this class but I wanted to see how they work. Here is my program and I would like to create a function for each of my menu options. I created a function to display and read the menu and the option that is entered, but I would like to...
C programming - This is what I have so far but it is not working correctly. It must contain the function and it also needs a provision to write output to a file. Can anyone help? #include <stdio.h> I #include <math.h int main (void) int V float Rint, RLE0, 0; printf New power supply voltage scanf ("td", &V) printf Enter a valid Internal Resistance (Rint) range between 200 and 5k ohms: scanf ("tf", Rint if (V> 1 && VK 15)...
Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...
I need little help with C language. I need to pass what I get from HexToBin(char* hexdec) into char* input so that what I got there it should pass it as string array parametr. Example: Enter IEEE-Hex: 40200000 Equivalent Binary value is : 01000000001000000000000000000000 Decimal Number: 2.5 #include <stdio.h> void HexToBin(char* hexdec) { long int i = 0; while (hexdec[i]) { switch (hexdec[i]) { case '0': printf("0000"); break;...
C linux please write it by only using “if and else” conditions, thanks so much this is my task 3 Requirements 1. Copy your solution for Task 3 t3.c to a new file t4.c. 2. The input is guaranteed to contain at least one non-whitespace character. 3. If the input is well-formed, i.e., can be parsed to a number, the program should behave identically to Task 3. All the requirements of Task 3 still apply except the file name. 4....
I am trying to change my code so i no longer need the function that reads in the users base and height input but rather uses the implementation of argument vector in C. I want to accept command line arguments and have it calculate my area. so i want to type this into the command line and have it calculate my area project1 5 4 #include <stdio.h> void userDimensions(float *base, float *height) { scanf("%f", base); scanf("%f", height); } float calcArea(float...
NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A FUNCTION. Problem are explained in bold #include <stdio.h> #include <string.h> #include <stdlib.h> #define pi 3.1415 void Area (double n); void VolSphere (double n); void Circumference (double n); void AllCalc (); // i dont know if the declaration of the function is correct AllCalc = AllCalculations //function main begins program execution int main (void) { puts("-Calculating Circle Circumference, Circle Area or Sphere Volume-\n"); void (*f[4])...