Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fall 2017 Lab Exam 1 CSCE 3600 (15 Points) Write a complete, working C program c

ID: 3586095 • Letter: F

Question

Fall 2017 Lab Exam 1 CSCE 3600 (15 Points) Write a complete, working C program called euidA.c (where "euid" is your EUID) that accepts one integral command-line argument and that will be used to dynamically allocate an array of that size: message that contains the name of the program called (i.e., the executable) and the expected parameter for the array size (see SAMPLE OUTPUT) and then terminate the .If the user does not enter the one integral command-line argument, print a "usage" program. Assume the command-line argument value given is integral and greater than I. o for the size of the array. This means that your array variable must be a pointer type to a Then, use a loop to prompt for and read in as many floating-point numbers into your .Compute the sum of all the floating-point numbers and print out the average of these Dynamically allocate an array of floating-point type using the command-line argument floating-point number array as specified in the command-line argument. numbers Be sure to deallocate any dynamically allocated memory. . Due to time constraints, no comments are required in this code, but please put your in comments in the program file. SAMPLE OUTPUT (user input in bold green): S./a.out 3 Enter a floating-point number: 3.24 Enter a floating-point number: 7.7 Enter a floating-point number: 4.3 The average of 3 numbers is 5.080000 $/a.out usage: .-/a.out array_size $/a.out 2 Enter a floating-point number: 6.46 Enter a floating-point number: 7.14 The average of 2 numbers is 6.800000. ts) Write a complete, working bash script called euidB (where "cuid" is your Due to Blackboard limitations, the name of this bash script should not have the .sh Write a function called product that accepts two integral parameters. This function will 2. (15 Point EUID) that does the following extension. simply calculate the product of the two integral command-line-arguments passed to the function and output a meaningful message along with the result In the main part of the function, you will check for the following: o If two command-line arguments are passed to the script um arguments and then call the product function arguments as parameters to the function , passing both command-line When finished before d, let your TA know you are done as you must check out with your TA leaving or your work will not be graded and you may receive a 0 for this exam!

Explanation / Answer

Code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[])
{
float *arr, sum=0;
int size, i=0;
if(argc<=1) {
printf("Arguments not passed");
}else{
size = atoi(argv[1]);
printf("%d",size);
arr = (float*) malloc(size * sizeof(float));
while(i<size){
printf("Enter floating point number: ");
scanf("%f",arr[i]);
sum+=arr[i];
i++;
}
printf("The average is: %f",sum);
}
return 0;
}