Solved CSE1320 HW1 Purpose: Gain experience in the mechanics of editing, compiling

$30.00

Original Work ?
Category: Tags: , , , , , , , You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Purpose:

  • Gain experience in the mechanics of editing, compiling, and executing a C program on a linux system.
  • Initial foray into C programming

 

Assignment:

 

Write a program that will calculate and display the mean, median, sum, max, and min of a provided sequence of 5  numbers.

 

  1. An array cannot be used. Global variables are OK, if you chose to use them.
  2. The only header you need is #include <stdio.h>
  3. The numbers will be hard coded as numeric literals. (clarification:  for each data set below, use assignment statements to initialize the variables with the desired input data.  This program requires no user input) Use the following input data:
    1. (25,5,0,0,2 )
    2. (0,0,0,0,0)
    3. (100,100,100,100,100)
    4. (1,2,3,4,5)
    5. (5,4,3,2,1)
  4. The program will be contained in a single C file.
  5. The program must contain the following functions:
    1. main
    2. mean
    3. median
    4. sum
    5. max
    6. min

The return types of these functions should be consistent with the result.  Example; The sum of two integers is always an integer, so an ‘int’ would be the correct return value for the “sum” function.

 

It is acceptable for functions to be used by other functions you have written for this assignment.

 

 

  1. Without arrays, ‘cut and paste’ will make the size of the program large. It is permissible but not required to use additional functions or macros to minimize the lines of code you have to write.
  2. Please turn in only the .c file. The grader will compile and execute the program.
  3. Output of the program should look like this:

 

25 5 0 0 2
min = 0 max = 25 median = 2 sum = 32 mean = 6.400000

0 0 0 0 0
min = 0 max = 0 median = 0 sum = 0 mean = 0.000000

100 100 100 100 100
min = 100 max = 100 median = 100 sum = 500 mean = 100.000000

1 2 3 4 5
min = 1 max = 5 median = 3 sum = 15 mean = 3.000000

5 4 3 2 1
min = 1 max = 5 median = 3 sum = 15 mean = 3.000000

  1. For this assignment, comments are not required.

 

Grading Criteria:

 

  • Program compiles and executes without warnings.
  • Output values are correct.
  • Compliance with assignment requirements.