Problem Set A

Problem Set A

1 .

For each of the following programming languages: investigate the language. Is the language low-level, middle-level, or high-level? Which of the paradigms covered in this section apply to the language (imperative, declarative, functional, structured, procedural, object-oriented)? Cite your sources.

  1. Kotlin
  2. Lisp
  3. PASCAL
2 .
Explain how levels of abstraction affect speed of development and speed of execution.
3 .
Explain how a compiler assists in providing abstractions for high-level languages.
4 .
Write a module titled “triangle operations” that has two functions: one to compute the area of a triangle given a base and height and one to compute the perimeter of the triangle given three sides. Then, write a main function that iterates three times, increasing each variable by one, and then calls each function.
5 .
OpenMP provides the omp_get_thread_num() function in the header file omp.h. To get the number of total running threads in the parallel block, you can use function omp_get_num_threads. How can you modify this program to ensure that only one thread executes the “Greetings from process” printf statement?
#include <stdio.h>
#include <omp.h>
 
int main() {
  #pragma omp parallel num_threads(3)
  {
  int id = omp_get_thread_num();
  int data = id;
  int total = omp_get_num_threads();
  printf("Greetings from process %d out of %d with Data %d\n", id, total, data);
  }
  printf("parallel for ends.\n");
  return 0;
}
6 .
Read the documentation on device drivers and implement the various examples provided.