Practice Exercises
1
.
List three pros or cons about each level of language in terms of execution time, complexity, readability, abstraction, and speed of development.
2
.
Write 8086 assembly code to add the values 1 and 3 together. The registers
abx
and cdx
are available to use for this operation and the result should be stored in abx
.3
.
Write a main function in C that calls another function to add the numbers 1 and 3 together and return the sum as an output parameter. Finally, print out the answer to the console.
4
.
Write a main method in Java that calls another method to add the numbers 1 and 3 together and then print out the answer to the console.
5
.
Write the GCC commands to compile file1.c, file2.c and file3.c and then link the object files to create a static library titled myLib.
6
.
Write a main function in C that calls a public function titled
PrintList()
in a module titled listOperations.7
.
Write a C module that includes 2 global integer variables declared in the file titled
variables.h
and then print the global variables in a main function that exists in main.c
.8
.
Write a Git command to pull changes from a repository on your local host machine with the URL “https://localhost/MyRepository” into your working repository checkout.
9
.
Write a GCC command to compile a C file titled
main.c
that includes a static library titled myStaticLib
.10
.
Trace the following C code and list the contents of the array after the iteration.
int main() {
int List[5];
int a = 10;
for (int i = 0; i < 5; i++)
{
List[i] = a + i;
}
return 0;
}
11
.
The following is a C “hello world” program that uses OpenMP. How many lines of messages will this program generate at runtime?
#include
int main() {
int x = 1;
int y = x + 2;
#pragma omp parallel num_threads(y * 3)
{
printf("https://helloacm.com\n");
}
return 0;
}
12
.
Write a C module that creates four threads to call a function that prints the thread number out.