Skip to content

Instantly share code, notes, and snippets.

@jtrent238
Created March 4, 2019 22:04
Show Gist options
  • Save jtrent238/7a1e5ec02ab65c2b9534974226195e7c to your computer and use it in GitHub Desktop.
Save jtrent238/7a1e5ec02ab65c2b9534974226195e7c to your computer and use it in GitHub Desktop.
// Programmer: Your Name
// Date: Date
// Program Name: The name of the program
// Chapter: Chapter # - Chapter name
// Description: 2 complete English sentences describing what the program does,
// algorithm used, etc.
#define _CRT_SECURE_NO_WARNINGS // Disable warnings (and errors) when using non-secure versions of printf, scanf, strcpy, etc.
#include <stdio.h> // Needed for working with printf and scanf
int main(void)
{
// Constant and Variable Declarations
const int ARRAY_SIZE_0 = 10;
const int ARRAY_SIZE_1 = 10;
const int ARRAY_SIZE_2 = 10;
double userArray0[ARRAY_SIZE_0];
double userArray1[ARRAY_SIZE_1];
double userArray2[ARRAY_SIZE_2];
// *** Your program goes here ***
for (int i = 0; i < ARRAY_SIZE_0; i++) {
printf("Enter array element #%d: ", i);
scanf("%lf", &userArray0[i]);
}
printf("\n"); //blank line
printf("The original array..." "\n");
printf("%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\n", userArray0[0], userArray0[1], userArray0[2], userArray0[3], userArray0[4], userArray0[5], userArray0[6], userArray0[7], userArray0[8], userArray0[9]);
userArray1[0] = userArray0[9];
userArray1[1] = userArray0[8];
userArray1[2] = userArray0[7];
userArray1[3] = userArray0[6];
userArray1[4] = userArray0[5];
userArray1[5] = userArray0[4];
userArray1[6] = userArray0[3];
userArray1[7] = userArray0[2];
userArray1[8] = userArray0[1];
userArray1[9] = userArray0[0];
printf("The reverse array..." "\n");
printf("%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\t" "%.0lf" "\n", userArray1[0], userArray1[1], userArray1[2], userArray1[3], userArray1[4], userArray1[5], userArray1[6], userArray1[7], userArray1[8], userArray1[9]);
userArray2[0] = (userArray0[0] + userArray1[0]) / 2;
userArray2[1] = (userArray0[1] + userArray1[1]) / 2;
userArray2[2] = (userArray0[2] + userArray1[2]) / 2;
userArray2[3] = (userArray0[3] + userArray1[3]) / 2;
userArray2[4] = (userArray0[4] + userArray1[4]) / 2;
userArray2[5] = (userArray0[5] + userArray1[5]) / 2;
userArray2[6] = (userArray0[6] + userArray1[6]) / 2;
userArray2[7] = (userArray0[7] + userArray1[7]) / 2;
userArray2[8] = (userArray0[8] + userArray1[8]) / 2;
userArray2[9] = (userArray0[9] + userArray1[9]) / 2;
printf("The average array..." "\n");
printf("%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\t" "%.1lf" "\n", userArray2[0], userArray2[1], userArray2[2], userArray2[3], userArray2[4], userArray2[5], userArray2[6], userArray2[7], userArray2[8], userArray2[9]);
printf("\n"); // blank line
return 0;
} // end main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment