Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Brief Documentation Guide Comments must be used to document the problem the code solves.  You should include at the very top of your code a comment that explains in detail the problem the code solves...

1 answer below »
Brief Documentation Guide

Comments must be used to document the problem the code solves.
 You should include at the very top of your code a comment that explains in detail the
problem the code solves and how it solves it.
Approximately 2 to 7 lines for labs
Approximately 7 to 30 lines for assignments
 Comments should explain any mathematics or formula used in the code.
 You should document the units of an indenter if it has related units, eg. metres.
 Comments should explain why an approach is taken, if there are multiple possible
approaches.
 Comments should explain what blocks or steps in your code do, if significant.
 A person that understands the fundamentals of C code should be able to read your code and
comments and know what it does without having to run it.
 You should not comment every line.
 You should explain when using iteration, what is being iterated.
 You do not have to explain C code to the reader unless asked.
 The number and size of comments is not a measure of how well you have documented your
code.
 Function descriptions must be used

Implicit documentation and style:
 Variables must be limited to an appropriate scope.
 Variables must be named appropriately such that they can be easily identified
 Early exiting from loops or functions are avoided unless necessary
 White space is used to separate various parts of the code for clarity
 Indentation style used is the Allman style
    Brief Documentation Guide
Answered Same Day May 09, 2020

Solution

Snehil answered on May 11 2020
148 Votes
main.c
#include#includedefining value for PI (11 digit precision)
#define PI 3.14159265358
Function prototypes
void calculate_impedance(double* result_table_impedance_real, double* result_table_impedance_imag, int components[], double values[], int n, int freq, int choice);
void print_results(double * result_table_impedance_real, double* result_table_impedance_imag,
double * result_table_cu
ent_real, double* result_table_cu
ent_imag,
double * result_table_voltage_real, double* result_table_voltage_imag, int n, int components[]);
void complex_addition(double in1_real, double in1_imag, double in2_real, double in2_imag, double* out3_real, double* out3_imag);
void complex_subtraction(double in1_real, double in1_imag, double in2_real, double in2_imag, double* out3_real, double* out3_imag);
void complex_multiplication(double in1_real, double in1_imag, double in2_real, double in2_imag, double* out3_real, double* out3_imag);
void complex_division(double in1_real, double in1_imag, double in2_real, double in2_imag, double* out3_real, double* out3_imag);
char* get_signed_
ackets_value(char* s, double num);
char* get_component_unit(char*s, int component_type);
char get_component_initial(int component_type);
main function
int main()
{
int n;
number of components
int* components;
component types
double* values;
component sizes
int choice;
user choice
int freq;
frequency
int source_voltage;
source voltage
printf("**%d %s**", 3777777, "John Smith Assignment 2");
do
loop to get user choice, runs till user provides valid choice
{
printf("\nDo you want to create a 1.Parallel or 2.Series circuit evaluation? ");
scanf("%d",&choice);
if(!(choice==1 || choice==2))
{
printf("Invalid Selection\n");
}
}while(!(choice==1 || choice==2));

get user input for frequency, source voltage and number of components
printf("Enter the frequency in Hertz of the source: ");
scanf("%d",&freq);
printf("Enter the source voltage: ");
scanf("%d",&source_voltage);
printf("How many components are in %s: ",choice==1?"parallel":"series");
scanf("%d",&n);

assigning memory to various pointers based on number of components
double* result_table_impedance_real= malloc(sizeof(double)*(n+1));
double* result_table_impedance_imag= malloc(sizeof(double)*(n+1));
double* result_table_cu
ent_real= malloc(sizeof(double)*(n+1));
double* result_table_cu
ent_imag= malloc(sizeof(double)*(n+1));
double* result_table_voltage_real= malloc(sizeof(double)*(n+1));
double* result_table_voltage_imag= malloc(sizeof(double)*(n+1));
components = malloc(sizeof(int)*n);
values = malloc(sizeof(double)*n);
int i;
char s[12];

get user input for component types and sizes
printf("\nEnter the component type for each component where 1 is Resistor, 2 is Capacitor and 3 is Inductor.\n");
for(i=0;i {
printf("Component %d: ",i+1);
scanf("%d",components+i);
printf("Enter the size of the component in %s: ",get_component_unit(s,components[i]));
scanf("%lf",values+i);
}

calling function to calculate impedance
calculate_impedance(result_table_impedance_real,result_table_impedance_imag,components,values, n, freq, choice);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here