Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a program add.c that reads an array (a1) of numbers, and creates a new array (a2) of numbers such that the first and last

write a program add.c that reads an array (a1) of numbers, and creates a new array (a2) of numbers such that the first and last numbers of a1 are added and stored as the first number. Here is the rest of the directions:

image text in transcribed

image text in transcribed

Rules:

1.Your program should begin with a comment that briefly summarizes what it does. This comment should also include your name

2.In most cases, a function should have a brief comment above its definition describing what it does. Other than that, comments should be written only needed in order for a reader to understand what is happening.

3.Variable names and function names should be sufficiently descriptive that a knowledgeable reader can easily understand what the variable means and what the function does. If this is not possible, comments should be added to make the meaning clear.

4.Use consistent indentation to emphasize block structure.

5.Full line comments inside function bodies should conform to the indentation of the codewhere they appear.

6.Macro definitions (#define) should be used for defining symbolic names for numericconstants. For example: #define PI 3.141592

7.Use names of moderate length for variables. Most names should be between 2 and 12 letters long.

8.Use underscores to make compound names easier to read, example: tot_vol or total_volumn is clearer than totalvolumn.

Project 2, IT Program Design 1. Write a program add.c that reads in an array (a1) of numbers, and creates a new array (a2) of numbers such that the first and last numbers of a1 are added and stored as the first number, the second and second-to-last numbers are stored as the second number, and so on. Note that you need to check for even and odd length of arrays. In case of an odd number of integers, leave the central integer in the original list as it is. In the main function, ask the user to enter the length of the array, declare the array with the length, and calculate and display the output array Example input/output #1 Enter the length of the array: 5 Enter the elements f the array: 8 4 1 3 9 Output: Example input/output #2 Enter the length of the array: 4 Enter the elements of the array: 3 4 1 7 Output: 10 5 2. Write a program three.c that include the following function int same three (nt atl, int n)i The same th function tests whether an nger rray has three numbers with the same value. The function returns the number if there are three numbers with the same value and return 0 if not. Hint: use three nested loops. Assume that 1) 2) 3) The array has at least three elements. All elements are non zero integers. There are no more than one set of three numbers with the same value In the main function, ask the user to enter the length of the array, declare the array with the length, and call the function. The main function should display the result

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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

=+6-3 Explain illusory correlations and regression toward the mean.

Answered: 1 week ago