Skip to ContentGo to accessibility page

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
Reuse and redistribution of this content in digital or print format:
  • 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 prior written permission.
  • This book uses the Creative Commons Attribution-NonCommercial-ShareAlike License, which means that you can reuse and modify the material only for noncommercial purposes, must attribute OpenStax, and must distribute any derivative works under the same license.
  • Any commercial printing of this textbook, including using a local or custom printer, must be approved by OpenStax, and proper citation provided.
  • OpenStax-copyrighted images, activities, assessments, and similar components of this book are subject to the same licensing – CC-BY-NC-SA. They can be used for noncommercial purposes with attribution. Commercial use requires permission.
  • Permission requests: Anyone who intends to incorporate this content (including text, images, and other components) into large language models, use it in AI offerings, use it commercially (including in print), and/or has questions about another use case is welcome to complete our reuse request form.
Attribution information
  • If you are redistributing all or part of this book in a noncommercial 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 noncommercial digital format, then for every page that includes OpenStax content, you must license the derivative work under the same CC-BY-NC-SA license as the original, and 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

The information below includes the information needed to generate citations in most major styles (APA, MLA, etc.); you must reformat and organize the information as needed to fit the requirements of the style. Use the information below to generate a citation. We recommend using a citation tool such as this one.

© Apr 23, 2026 OpenStax. Textbook content produced by OpenStax is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike License. The OpenStax name, OpenStax logo, OpenStax book covers, OpenStax CNX name, and OpenStax CNX logo, and Rice University name, and Rice University logo trademarks, or wordmarks are not subject to the Creative Commons license and may not be reproduced without the prior and express written consent of Rice University.