Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language programing 2 don't kniw what's wrong In this programming assignment, you will write a C program that uses input, output, function calls, and

C language programing 2 don't kniw what's wrong image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this programming assignment, you will write a C program that uses input, output, function calls, and preprocessor directives for doing some basic mathematical computations. You will also organize your program into separate source and header files. Create a header file named functions. In this file, you will do the following Include the header guards Write a preprocessor directive to representa constant value for an array size. Name it LENGTH and give the replacement values You will write two functions (see below functions.c) Declore their prototypes, Function names should be exactly as shown below Create a source file named functions. In this file, you will do the following o Write a function named average () that takes in an array of integers. It returns the average of the array as a double value. Use "pass by value Write a function named quadraticFormula() that solves for the two x values. It takes in five parameters the arguments for the equation a, b, and c plus two parameters passed by pointer/reference so that the both x valuen (xi and x2) can be sent back to the caller. Assume all parameters are of type double. The function retums nothing. Here is the mathematical formula below (source: Wildpedia) -6/6 - Mac 2 o Assume that a > and the value under the root is always greater than leb2 > 4C The first result x1 is when you add the square root expression and the second result x2 is when you subtract the square rool expression No printf() statements can exist in these functions in this file. All printing will happen in main Write the main that will do the following Declare an array with 5 integer values use the LENGTH . Using a for loop, ask the user to input a value for each of the array elements. Assume the user will always enter a valid value 180 input Next, ask the user for three values a, b indenrguments that will be passed to the quadraticFormula) Yunction. It will pass two additional variables by pointer Call the average () function with the array is the argument Call the quadraticFormula) with the arguments abc and the result variables XI and X2 passed by reference Print the results. First line should print the average of the army Next print the updated result value for XI ond X2 cachina separate line The output must look exactly like below in terms of formatting. There is only one since between the colon and the result Results are shown with exactly two decimal place. The example shows the solutions for when the array contains [10, 20, 30, 40, 50] and when a = 2,5 - 5. and c = -3 functions.c:4:7: warning: type defaults to 'int' in declaration of 'LENGTH" I-Wimplicit-int 4 const LENGTH = 5; 1.LENGTH A 011 Compilation failed main.c: In function 'test Passed: main.c:30:8: Orar: LENGTH" undeclared first in this function 30 if( LENGTH = 5) main.c:30:8: note: each undeclared identifier is roported only onco con main.c:37:1: Warning: control roaches and of nonvoid function I- Wur 371) Compilation failed functions 4:7: warning: type defaults tot in declaration E zyBooks catalog Help/FAQ ation failed n.c:30:8: note: each undeclared identifier is reported only once for each n.c:37:1: warning: control reaches end of non-void function -Wreturn-ty! 371) 1 Ictions.c:1:7: warning: type defaults to 'int' in declaration of LENGTH 4 const LENGTH= 5; 0/3 lation failed main.c: In function 'test passed': main.c: 49:16: Orror: LENGTH' undeclared first use in this function) 491 int array( LENGTH 180, 20, 90, 70, 30 ) main.c:49:16: note: each undeclared identifier is reported only once to main.c: In function 'testPassed': main.c: 49:16: error: LENGTH' undeclared (first use in this function) 491 int array LENGTH 1 = [ 80, 20, 90, 70, 30); lation failed main.c:49:16: note: each undeclared identifier is reported only once to main.c: 49:9: warning: unused variable array' l-Wunused-variable) 49 int array LENGTH 1 = ( 80, 20, 90, 70, 30): functions.c:4:7: warning: type defaults to 'int' in declaration of "LEN 4 const LENGTH = 5; 22 03 main.c: In function test Passed': main.c:49:17: error: LENGTH' undeclared (first use in this function) 49 int array1 LENGTH 1 = ( 17, 23, 19, 11, 4); ded main.c:49:17: note: each undeclared identifier is reported only once for main.c:49:9: warning: unused variable arrayl' [-Wunused-variable] 491 int array( LENGTH 1 = ( 17, 23, 19, 11, 4); AN functions.c:4:7: warning: type defaults to 'int' in declaration of 'LEN 4 const LENGTH = 5; 0/3 iled main.c: In function 'testPassed': main.c:47:4: warning: implicit declaration of function 'quadraticFormul 471 quadraticFormula ( 30, 17, -39, &xl, 6x2); 1 quadFormula functions.c:4:7: warning: type defaults to 'int' in declaration of 'LEN 4 const LENGTH = 5; ed /usr/bin/id: /tmp/ccfunlHa.o: in function testPassed': main.c: (.text+0x170): undefined reference to quadraticFormula! collect2: error: ld returned 1 exit status 212 anput 10 20 30 40 50 2 5 -3 20.240.201 (du... 19.4. Programming - 0018 - 2K OS 10 ATX 00 Os oberene sulejo 110 indino inox 10 20 30 40 50 2 5 -3 indu) vindino sjedwoo 9 A

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions