BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | COMP1511 Programming Fundamentals

C语言代写 | COMP1511 Programming Fundamentals

本次澳洲代写主要为C语言编程基础相关的限时测试

Language Restrictions

All questions must be answered entirely in C. You may not use other programming languages, e.g. you may not use Python.

Your C program can not run external programs, e.g. it can not call the function system().

You are not permitted to use functions from C libraries other than the standard C libraries (stdio.h, stdlib.h, string.h, math.h, ctype.h, assert.h).

Individual questions may specify C features you are not permitted to use or C functions you are not permitted to use.

You can not use the -l option to dcc.

Setup
This exam comes with starter files. You can access them by running:

1511 fetch-pracexam

This gives you a file in which to write answers to the short answer questions. This file, named prac_mc.txt, is the template into which you should put your responses to each multiple-choice question.

This also gives you starter files for each programming question.

To test your code, run the command:

1511 autotest-pracexam prac_q1

Short Answer Questions (20 marks total)
Note: The files mentioned in the following questions are not copied by 1511 fetch-pracexam. The file names are just to show how they were compiled.
Short Answer Question 1 (1 mark)
Imagine a file named part1_q1.c contains this C Code (amongst other code):

int x = 11;
int y = 3;
printf(“%d\n”, x / y);
part1_q1.c is compiled with dcc on a CSE machine like this:

dcc part1_q1.c -o part1_q1

It compiles successfully. No errors or warnings are produced by dcc. The program is run like this:

./part1_q1
What does this program print?

Enter as your answer the output the code snippet produces.

Enter this answer in the file prac_mc.txt, after the [q1], inside the curly brackets.

Do not enter any extra characters. Do not write \n for a newline character. Do not enter any explanation.

Enter just the output the program produces.

If the program prints an error message just write ERROR. Do not enter the exact error message.

Short Answer Question 2 (1 mark)
Imagine a file named part1_q2.c contains this C Code:
#include <stdio.h>

#define STOP_NUMBER 100

int main(int argc, char *argv[]) {
int monkey = 1;
int i = 0;
while (i < STOP_NUMBER) {
monkey += i;
i++;
}
printf(“Total is: %d\n”, monkey);
}
Which of the following Code Style Issues are present in this code?

A: Inconsistent Indentation
B: Bad Variable name(s)
C: Overly Deep Nesting
D: Lack of use of constants
Enter the answer(s) in the file prac_mc.txt, after the [q2], inside the curly brackets.

This question can have more than one answer and a correct answer will identify all the issues in the code.

For example, if you think that A and C are the correct answers, your answer will be: AC

If you think that D alone is the correct answer, your answer will be: D

Short Answer Question 3 

The file part1_q3.c contains this C Code:

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

struct node {
int data;
struct node *next;
};

int main(void) {
struct node *head = malloc(<YOUR CODE HERE>);
}
What code should replace <YOUR CODE HERE> ?

Enter as your answer as the exact text you would write in this program.

Enter this answer in the file prac_mc.txt, after the [q3], inside the curly brackets.

Do not enter any extra characters. Do not write \n for a newline character. Do not enter any explanation.

You can check your answers are in the correct format with 1511 autotest-pracexam prac_mc
You can submit the question with give cs1511 prac_mc prac_mc.txt
There will be 20 Short Answer questions in the exam. See the lab exercise for more information.
Practical Questions

Question 1

Passing this question, or question 3, is sufficient to pass the Arrays Hurdle.
Your task is to add code to this function:

// Return the maximum sum of a row in the 2D array.
int max_row_sum(int array[TEST_ARRAY_SIZE][TEST_ARRAY_SIZE], int side_length) {
// PUT YOUR CODE HERE (you must change the next line!)
return 42;
}
Add code so that max_row_sum finds the row in the square two dimensional array with the highest sum, and returns that value. You are guaranteed the array will only contain positive numbers.
For example if the array is a 3 height by 3 width array

6, 7, 8,
1, 1, 9,
3, 2, 8
Your function should return 21 because:

6 + 7 + 8 == 21
1 + 1 + 9 == 11
3 + 2 + 8 == 13

As you can see, the largest row sum is 21.

Testing

prac_q1.c also contains a simple main function which allows you to test your max_row_sum function.
Your max_row_sum function will be called directly in marking. The main function is only to let you test your max_row_sum function

Assumptions/Restrictions/Clarifications.

max_row_sum should return a single integer.
max_row_sum should not change the array it is given.

max_row_sum should not call scanf (or getchar or fgets).

max_row_sum can assume the array contains at least one integer.

max_row_sum function should not print anything. It should not call printf.

Your submitted file may contain a main function. It will not be tested or marked.

You can autotest this code with 1511 autotest-pracexam prac_q1
You can submit this code with give cs1511 prac_q1 prac_q1.c
You can check your submission has been accepted with 1511 classrun -check prac_q1

bestdaixie

评论已关闭。