Programming Fundamentals Practice Language Restrictions - IT Assignment Help

Download Solution Order New Solution
Assignment Task:

Task:

Short Answer Questions
Note: The files mentioned in the following questions are not copied by 1091 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:

 

https://cgi.cse.unsw.edu.au/~dp1091/21T1/prac_exam/papers/ 3/7
Practical Questions
#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 (1 mark)
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.

 

Practical Questions
#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 (1 mark)
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 1091 autotest-pracexam prac_mc
You can submit the question with give dp1091 prac_mc prac_mc.txt

There will be 20 Short Answer questions in the exam. See the lab exercise for more information.

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

22/04/2021 Programming Fundamentals Exam

https://cgi.cse.unsw.edu.au/~dp1091/21T1/prac_exam/papers/ 4/7

// 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

 

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.

 

This  IT Assignment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.