Computer Science Courses
COMP6300
Related sites
Students are expected to attempt all of the questions in the Multi choice, Short answer and Lab quesitons BEFORE the lab time.
#include<stdio.h> void fun(int x) { x = 6; } int main() { int y; y = 5; fun(y); printf("%d",y); }
A) 4 | B) 5 | C) 6 | D) 7 |
for (i=0;i<4;i++) { for (j=i;j<4;j++) { printf('a'); } }
A) 16 | B) 4 | C) 10 | D) 17 |
A) 3 | B) 4 | C) 5 | D) 6 |
A) return false. | B) not compile. | C) evaluate to 1. | D) use integer comparison. |
#define TIMESTWO(A) (2*A)
the expression "TIMESTWO(2+4)" would
A) evaluate to 12. | B) evaluate to 8. | C) evaluate to 10. | D) evaluate to 6. |
A) are terminated by a null. | B) are terminated by a -1. | C) store their length in an int. | D) are terminated by a ''. |
int array[] = {2,5,3,9};
The expression "array[array[0]]" would ________
A) evaluate to 5. | B) not compile. | C) evaluate to 2. | D) evaluate to 3. |
int array[] = {7,5,3,9};
The expression "array[0] + array[2]" would evaluate to _____ .
A) 11 | B) 7 | C) 14 | D) 10 |
char str[] = "Hello!";str[3] = 0;
The length of the string 'str' would be?
A) 0 | B) 2 | C) 3 | D) 6 |
______________ continue it onto the next line.
A) use backslash () to | B) use hash (#) to | C) not | D) use star (*) to |
int i;for(i=0;i=10;i++) { printf("%d ",i);}
A) Not compile due to a syntax error. | B) Print 0, 1, ... up to 9. | C) Print "10 " repeatedly forever! | D) Print nothing. |
% echo "Eric" | ./welcomeHello Eric
~/courses/ics/labs/lab2code$ cat test.nums3.07.26.09.51.0~/courses/ics/labs/lab2code$ cat test.nums | ./averageaverage 5.340000
Note you can also type the numbers directly into the terminal, just use Ctl-d to mark the end of file.
Add to the above program the ability to also calculate the minimum and the maximum
In a group of 2 or 3 in the c programming language implement a program that takes a list of numbers on standard input and finds if any 3 numbers sum to 100.
If there are 3 numbers that sum to 100 then output "yes" otherwise output "no".
You can use a simple approach that loads the numbers in any array and uses three nested loops with a check for summing to 100 in the middle.
There are 4 simple test files you can use to help check your implementation.
, , , .
There are three aspects we would like to find out about this program:
<li>what system calls does it use (run your program with "strace" to find this out),</li> <li>how long does it take to execute test3no.txt (run your program with "time"),</li> <li>how big is the source code in terms of lines and characters (use "wc").</li>
Share the results using the whiteboard with the rest of the class.
It would be good to have a few people also implement the same task in some different programming languages such as Java, python, haskell, ...
and compare it with that of c in terms of performance, code size, system calls, code readability, and code complexity.
Updated: 16 May 2016 / Responsible Officer: JavaScript must be enabled to display this email address. / Page Contact: JavaScript must be enabled to display this email address. / Powered by: Snorkel 1.4
+61 2 6125 5111
The Australian National University, Canberra
CRICOS Provider : 00120C
ABN : 52 234 063 906