SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
Please can this be done in C not c++ and can it have comments in the code to explain the
structure of the code and can the variable names be at least 6 characters long
Revise the code bellow so that the program prompts the user to specify the number of
voltage readings that are re to be stored in an array. Also calculate the precision of the data
based on the voltage readings.
PLEASE ADD AN EXAMPLE OF THE CODE WOKING IN THE FORM OF A
OUTPUT EXAMPLE.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_VALUES 10 // Maximum number of sensor voltage values to be entered
#define CTV 1.8 // Current True Value of the sensor
int main()
{
double values[MAX_VALUES]; // Array to store sensor voltage values
int num_values; // Number of sensor voltage values entered by user
double v_min, v_max, v_ave, abs_acc, rel_acc, precision, sum, sd, diff;
int i;
printf("Enter the number of sensor voltage values (up to %d): ", MAX_VALUES);
if (scanf_s("%d", &num_values) != 1 || num_values < 2 || num_values > MAX_VALUES) {
printf("Invalid input. Exiting program.n");
return 1;
}
printf("Enter the sensor voltage values: ");
for (i = 0; i < num_values; i++) {
if (scanf_s("%lf", &values[i]) != 1) {
printf("Invalid input. Exiting program.n");
return 1;
}
}
// Find the minimum and maximum sensor voltage values
v_min = v_max = values[0];
for (i = 1; i < num_values; i++) {
if (values[i] < v_min) {
v_min = values[i];
}
else if (values[i] > v_max) {
v_max = values[i];
}
}
// Calculate the average sensor voltage value
sum = 0.0;
for (i = 0; i < num_values; i++) {
sum += values[i];
}
v_ave = sum / num_values;
// Calculate the absolute accuracy
abs_acc = fmax(fabs(v_max - CTV), fabs(CTV - v_min));
// Calculate the relative accuracy
diff = fabs(v_ave - CTV);
rel_acc = (diff / CTV) * 100.0;
// Calculate the precision
precision = fmax(fabs(v_ave - v_min), fabs(v_max - v_ave));
// Calculate the standard deviation
sum = 0.0;
for (i = 0; i < num_values; i++) {
sum += pow(values[i] - v_ave, 2);
}
sd = sqrt(sum / (num_values - 1));
// Print the results
printf("Results:n");
printf("Absolute accuracy: %f Vn", abs_acc);
printf("Relative accuracy: %f %%n", rel_acc);
printf("Precision: %f Vn", precision);
printf("Standard deviation: %f Vn", sd);
return 0;
}
Please can this be done in C not c++ and can it have comments in the c.pdf

Mais conteúdo relacionado

Semelhante a Please can this be done in C not c++ and can it have comments in the c.pdf

Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersSheila Sinclair
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programmingIcaii Infotech
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfAshutoshprasad27
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxAshutoshprasad27
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfadianantsolutions
 
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfC++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfandreaplotner1
 
Lecture 5Arrays on c++ for Beginner.pptx
Lecture 5Arrays on c++ for Beginner.pptxLecture 5Arrays on c++ for Beginner.pptx
Lecture 5Arrays on c++ for Beginner.pptxarjurakibulhasanrrr7
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solutionKuntal Bhowmick
 
computer programming Control Statements.pptx
computer programming Control Statements.pptxcomputer programming Control Statements.pptx
computer programming Control Statements.pptxeaglesniper008
 
Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3Synapseindiappsdevelopment
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical FileAshwin Francis
 

Semelhante a Please can this be done in C not c++ and can it have comments in the c.pdf (20)

Array Cont
Array ContArray Cont
Array Cont
 
C programm.pptx
C programm.pptxC programm.pptx
C programm.pptx
 
Declaration of variables
Declaration of variablesDeclaration of variables
Declaration of variables
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
 
C important questions
C important questionsC important questions
C important questions
 
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdfC++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
C++ code only(Retrieve of Malik D., 2015, p. 742) Programming Exer.pdf
 
Lecture 5Arrays on c++ for Beginner.pptx
Lecture 5Arrays on c++ for Beginner.pptxLecture 5Arrays on c++ for Beginner.pptx
Lecture 5Arrays on c++ for Beginner.pptx
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 
CHAPTER 5
CHAPTER 5CHAPTER 5
CHAPTER 5
 
computer programming Control Statements.pptx
computer programming Control Statements.pptxcomputer programming Control Statements.pptx
computer programming Control Statements.pptx
 
Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
C code examples
C code examplesC code examples
C code examples
 
Statement
StatementStatement
Statement
 

Mais de a1salesagency

Please explain in detail and show all steps! a) Assuming all responses.pdf
Please explain in detail and show all steps! a) Assuming all responses.pdfPlease explain in detail and show all steps! a) Assuming all responses.pdf
Please explain in detail and show all steps! a) Assuming all responses.pdfa1salesagency
 
Please explain in steps how to Add an index-html file and how to Uploa.pdf
Please explain in steps how to Add an index-html file and how to Uploa.pdfPlease explain in steps how to Add an index-html file and how to Uploa.pdf
Please explain in steps how to Add an index-html file and how to Uploa.pdfa1salesagency
 
Please Explain Cost of Materials Issuances Under the FIFO Method An in.pdf
Please Explain Cost of Materials Issuances Under the FIFO Method An in.pdfPlease Explain Cost of Materials Issuances Under the FIFO Method An in.pdf
Please Explain Cost of Materials Issuances Under the FIFO Method An in.pdfa1salesagency
 
Please explain answer 8- Write the simplified expression for the Boole.pdf
Please explain answer 8- Write the simplified expression for the Boole.pdfPlease explain answer 8- Write the simplified expression for the Boole.pdf
Please explain answer 8- Write the simplified expression for the Boole.pdfa1salesagency
 
Please examine the figure- -IV- represents- A ribosome A nuclear pore.pdf
Please examine the figure- -IV- represents- A ribosome A nuclear pore.pdfPlease examine the figure- -IV- represents- A ribosome A nuclear pore.pdf
Please examine the figure- -IV- represents- A ribosome A nuclear pore.pdfa1salesagency
 
Please DRAW out how to solve this problem In Drosophila- the genes j a.pdf
Please DRAW out how to solve this problem In Drosophila- the genes j a.pdfPlease DRAW out how to solve this problem In Drosophila- the genes j a.pdf
Please DRAW out how to solve this problem In Drosophila- the genes j a.pdfa1salesagency
 
Please do this in writing form We are learning about the life cycle of.pdf
Please do this in writing form We are learning about the life cycle of.pdfPlease do this in writing form We are learning about the life cycle of.pdf
Please do this in writing form We are learning about the life cycle of.pdfa1salesagency
 
Please create an ERD based on the following configuration in MYSQL- Th.pdf
Please create an ERD based on the following configuration in MYSQL- Th.pdfPlease create an ERD based on the following configuration in MYSQL- Th.pdf
Please create an ERD based on the following configuration in MYSQL- Th.pdfa1salesagency
 
Please code this method for me in Java- StringList is an interface bo.pdf
Please code this method for me in Java-  StringList is an interface bo.pdfPlease code this method for me in Java-  StringList is an interface bo.pdf
Please code this method for me in Java- StringList is an interface bo.pdfa1salesagency
 
Please create a Gantt chart visualisation of the project schedule- Act.pdf
Please create a Gantt chart visualisation of the project schedule- Act.pdfPlease create a Gantt chart visualisation of the project schedule- Act.pdf
Please create a Gantt chart visualisation of the project schedule- Act.pdfa1salesagency
 
please code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdfplease code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdfa1salesagency
 
Please choose the riiiight answer 11-Cyclical unemployment is caused b.pdf
Please choose the riiiight answer 11-Cyclical unemployment is caused b.pdfPlease choose the riiiight answer 11-Cyclical unemployment is caused b.pdf
Please choose the riiiight answer 11-Cyclical unemployment is caused b.pdfa1salesagency
 
Please can I get the answers ASAP Which of the following for loops wil.pdf
Please can I get the answers ASAP Which of the following for loops wil.pdfPlease can I get the answers ASAP Which of the following for loops wil.pdf
Please can I get the answers ASAP Which of the following for loops wil.pdfa1salesagency
 
Please calculate the labor force participation rate given the followi.pdf
Please calculate the  labor force participation rate given the followi.pdfPlease calculate the  labor force participation rate given the followi.pdf
Please calculate the labor force participation rate given the followi.pdfa1salesagency
 
PLEASE ANSWER URGENTLY! 15- Which of the following term is true about.pdf
PLEASE ANSWER URGENTLY!  15- Which of the following term is true about.pdfPLEASE ANSWER URGENTLY!  15- Which of the following term is true about.pdf
PLEASE ANSWER URGENTLY! 15- Which of the following term is true about.pdfa1salesagency
 
Please answer these following questions Competency7- Informatics and.pdf
Please answer these following questions Competency7-  Informatics and.pdfPlease answer these following questions Competency7-  Informatics and.pdf
Please answer these following questions Competency7- Informatics and.pdfa1salesagency
 
Please answer- Grade 12 Biology Please answer- Grade 12 Biology The e.pdf
Please answer- Grade 12 Biology Please answer- Grade 12 Biology  The e.pdfPlease answer- Grade 12 Biology Please answer- Grade 12 Biology  The e.pdf
Please answer- Grade 12 Biology Please answer- Grade 12 Biology The e.pdfa1salesagency
 
Please answer the three questions- Ty 1- When humans cause a change in.pdf
Please answer the three questions- Ty 1- When humans cause a change in.pdfPlease answer the three questions- Ty 1- When humans cause a change in.pdf
Please answer the three questions- Ty 1- When humans cause a change in.pdfa1salesagency
 
Please answer the question asap and i will surely upvote the answer (D (1).pdf
Please answer the question asap and i will surely upvote the answer (D (1).pdfPlease answer the question asap and i will surely upvote the answer (D (1).pdf
Please answer the question asap and i will surely upvote the answer (D (1).pdfa1salesagency
 
please answer the following - Please select all that apply- 1- Some co.pdf
please answer the following - Please select all that apply- 1- Some co.pdfplease answer the following - Please select all that apply- 1- Some co.pdf
please answer the following - Please select all that apply- 1- Some co.pdfa1salesagency
 

Mais de a1salesagency (20)

Please explain in detail and show all steps! a) Assuming all responses.pdf
Please explain in detail and show all steps! a) Assuming all responses.pdfPlease explain in detail and show all steps! a) Assuming all responses.pdf
Please explain in detail and show all steps! a) Assuming all responses.pdf
 
Please explain in steps how to Add an index-html file and how to Uploa.pdf
Please explain in steps how to Add an index-html file and how to Uploa.pdfPlease explain in steps how to Add an index-html file and how to Uploa.pdf
Please explain in steps how to Add an index-html file and how to Uploa.pdf
 
Please Explain Cost of Materials Issuances Under the FIFO Method An in.pdf
Please Explain Cost of Materials Issuances Under the FIFO Method An in.pdfPlease Explain Cost of Materials Issuances Under the FIFO Method An in.pdf
Please Explain Cost of Materials Issuances Under the FIFO Method An in.pdf
 
Please explain answer 8- Write the simplified expression for the Boole.pdf
Please explain answer 8- Write the simplified expression for the Boole.pdfPlease explain answer 8- Write the simplified expression for the Boole.pdf
Please explain answer 8- Write the simplified expression for the Boole.pdf
 
Please examine the figure- -IV- represents- A ribosome A nuclear pore.pdf
Please examine the figure- -IV- represents- A ribosome A nuclear pore.pdfPlease examine the figure- -IV- represents- A ribosome A nuclear pore.pdf
Please examine the figure- -IV- represents- A ribosome A nuclear pore.pdf
 
Please DRAW out how to solve this problem In Drosophila- the genes j a.pdf
Please DRAW out how to solve this problem In Drosophila- the genes j a.pdfPlease DRAW out how to solve this problem In Drosophila- the genes j a.pdf
Please DRAW out how to solve this problem In Drosophila- the genes j a.pdf
 
Please do this in writing form We are learning about the life cycle of.pdf
Please do this in writing form We are learning about the life cycle of.pdfPlease do this in writing form We are learning about the life cycle of.pdf
Please do this in writing form We are learning about the life cycle of.pdf
 
Please create an ERD based on the following configuration in MYSQL- Th.pdf
Please create an ERD based on the following configuration in MYSQL- Th.pdfPlease create an ERD based on the following configuration in MYSQL- Th.pdf
Please create an ERD based on the following configuration in MYSQL- Th.pdf
 
Please code this method for me in Java- StringList is an interface bo.pdf
Please code this method for me in Java-  StringList is an interface bo.pdfPlease code this method for me in Java-  StringList is an interface bo.pdf
Please code this method for me in Java- StringList is an interface bo.pdf
 
Please create a Gantt chart visualisation of the project schedule- Act.pdf
Please create a Gantt chart visualisation of the project schedule- Act.pdfPlease create a Gantt chart visualisation of the project schedule- Act.pdf
Please create a Gantt chart visualisation of the project schedule- Act.pdf
 
please code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdfplease code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdf
 
Please choose the riiiight answer 11-Cyclical unemployment is caused b.pdf
Please choose the riiiight answer 11-Cyclical unemployment is caused b.pdfPlease choose the riiiight answer 11-Cyclical unemployment is caused b.pdf
Please choose the riiiight answer 11-Cyclical unemployment is caused b.pdf
 
Please can I get the answers ASAP Which of the following for loops wil.pdf
Please can I get the answers ASAP Which of the following for loops wil.pdfPlease can I get the answers ASAP Which of the following for loops wil.pdf
Please can I get the answers ASAP Which of the following for loops wil.pdf
 
Please calculate the labor force participation rate given the followi.pdf
Please calculate the  labor force participation rate given the followi.pdfPlease calculate the  labor force participation rate given the followi.pdf
Please calculate the labor force participation rate given the followi.pdf
 
PLEASE ANSWER URGENTLY! 15- Which of the following term is true about.pdf
PLEASE ANSWER URGENTLY!  15- Which of the following term is true about.pdfPLEASE ANSWER URGENTLY!  15- Which of the following term is true about.pdf
PLEASE ANSWER URGENTLY! 15- Which of the following term is true about.pdf
 
Please answer these following questions Competency7- Informatics and.pdf
Please answer these following questions Competency7-  Informatics and.pdfPlease answer these following questions Competency7-  Informatics and.pdf
Please answer these following questions Competency7- Informatics and.pdf
 
Please answer- Grade 12 Biology Please answer- Grade 12 Biology The e.pdf
Please answer- Grade 12 Biology Please answer- Grade 12 Biology  The e.pdfPlease answer- Grade 12 Biology Please answer- Grade 12 Biology  The e.pdf
Please answer- Grade 12 Biology Please answer- Grade 12 Biology The e.pdf
 
Please answer the three questions- Ty 1- When humans cause a change in.pdf
Please answer the three questions- Ty 1- When humans cause a change in.pdfPlease answer the three questions- Ty 1- When humans cause a change in.pdf
Please answer the three questions- Ty 1- When humans cause a change in.pdf
 
Please answer the question asap and i will surely upvote the answer (D (1).pdf
Please answer the question asap and i will surely upvote the answer (D (1).pdfPlease answer the question asap and i will surely upvote the answer (D (1).pdf
Please answer the question asap and i will surely upvote the answer (D (1).pdf
 
please answer the following - Please select all that apply- 1- Some co.pdf
please answer the following - Please select all that apply- 1- Some co.pdfplease answer the following - Please select all that apply- 1- Some co.pdf
please answer the following - Please select all that apply- 1- Some co.pdf
 

Último

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 

Último (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 

Please can this be done in C not c++ and can it have comments in the c.pdf

  • 1. Please can this be done in C not c++ and can it have comments in the code to explain the structure of the code and can the variable names be at least 6 characters long Revise the code bellow so that the program prompts the user to specify the number of voltage readings that are re to be stored in an array. Also calculate the precision of the data based on the voltage readings. PLEASE ADD AN EXAMPLE OF THE CODE WOKING IN THE FORM OF A OUTPUT EXAMPLE. #include <stdio.h> #include <stdlib.h> #include <math.h> #define MAX_VALUES 10 // Maximum number of sensor voltage values to be entered #define CTV 1.8 // Current True Value of the sensor int main() { double values[MAX_VALUES]; // Array to store sensor voltage values int num_values; // Number of sensor voltage values entered by user double v_min, v_max, v_ave, abs_acc, rel_acc, precision, sum, sd, diff; int i; printf("Enter the number of sensor voltage values (up to %d): ", MAX_VALUES); if (scanf_s("%d", &num_values) != 1 || num_values < 2 || num_values > MAX_VALUES) { printf("Invalid input. Exiting program.n"); return 1; } printf("Enter the sensor voltage values: "); for (i = 0; i < num_values; i++) { if (scanf_s("%lf", &values[i]) != 1) { printf("Invalid input. Exiting program.n"); return 1; } } // Find the minimum and maximum sensor voltage values v_min = v_max = values[0]; for (i = 1; i < num_values; i++) { if (values[i] < v_min) { v_min = values[i]; } else if (values[i] > v_max) { v_max = values[i];
  • 2. } } // Calculate the average sensor voltage value sum = 0.0; for (i = 0; i < num_values; i++) { sum += values[i]; } v_ave = sum / num_values; // Calculate the absolute accuracy abs_acc = fmax(fabs(v_max - CTV), fabs(CTV - v_min)); // Calculate the relative accuracy diff = fabs(v_ave - CTV); rel_acc = (diff / CTV) * 100.0; // Calculate the precision precision = fmax(fabs(v_ave - v_min), fabs(v_max - v_ave)); // Calculate the standard deviation sum = 0.0; for (i = 0; i < num_values; i++) { sum += pow(values[i] - v_ave, 2); } sd = sqrt(sum / (num_values - 1)); // Print the results printf("Results:n"); printf("Absolute accuracy: %f Vn", abs_acc); printf("Relative accuracy: %f %%n", rel_acc); printf("Precision: %f Vn", precision); printf("Standard deviation: %f Vn", sd); return 0; }