Skip to ContentGo to accessibility pageKeyboard shortcuts menu
OpenStax Logo

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.

Citation/Attribution

This book may not be used in the training of large language models or otherwise be ingested into large language models or generative AI offerings without OpenStax's permission.

Want to cite, share, or modify this book? This book uses the Creative Commons Attribution License and you must attribute OpenStax.

Attribution information
  • If you are redistributing all or part of this book in a print format, then you must include on every physical page the following attribution:
    Access for free at https://openstax.org/books/introduction-computer-science/pages/1-introduction
  • If you are redistributing all or part of this book in a digital format, then you must include on every digital page view the following attribution:
    Access for free at https://openstax.org/books/introduction-computer-science/pages/1-introduction
Citation information

© Oct 29, 2024 OpenStax. Textbook content produced by OpenStax is licensed under a Creative Commons Attribution License . The OpenStax name, OpenStax logo, OpenStax book covers, OpenStax CNX name, and OpenStax CNX logo are not subject to the Creative Commons license and may not be reproduced without the prior and express written consent of Rice University.