100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Examen

CECS 325 Midterm Review Exam (REAL) | With Verified Answers

Puntuación
-
Vendido
-
Páginas
9
Grado
A
Subido en
25-03-2025
Escrito en
2024/2025

CECS 325 Midterm Review Exam (REAL) | With Verified Answers What is the first thing you need to do in order to use pthread? #include <pthread.h> How would you compile a C++ program with multithreading capabilities in the Linux Terminal? c++ -lpthread -o program What is the first parameter in pthread_create? thread, initialized as pthread_t t1; on a previous line in order to pass information on the thread through a variable What is the 2nd parameter in pthread_create? attribute, not necessary for our class but it's a pointer to a structure that can define thread attributes such as stack address etc What should you pass through the 2nd parameter in pthread_create by default? NULL What is the 3rd parameter in pthread_create? the function in which you want to run through the thread, EX: mySort Do functions in the 3rd parameter of pthread_create include their own parameters? NO, the 4th parameter of pthread_create includes the function's parameters. What is the 4th parameter in pthread_create? arg (arglist), pointer to void that contains the arguments to the function defined in the earlier argument What is the function to terminate a thread? void pthread_exit(void *retval); What is the function to make a thread wait? pthread_join(thread1, NULL); Why is the pthread_join function usually required? We need to wait till the threads are complete, otherwise the main function will continue while the threads are processing, risking termination of the program(return 0;) before the threads are completed. How do you declare a string in C/C++? (cstring) char s[5]; can visualize it as an array with 5 element slots What should always be included at the end of a C/C++ string? (cstring) 0, or null pointer Is char a[4] = ('a', 'b', 'c', 'd') valid? (cstring) no, assigning 5 characters to a string that has 4 characters. 0 is automatically initialized as the end of any given string. What is the strlen() function? takes a string as its argument and returns the string's length, excluding the 0 at the end. ''' int strlen(char n []) { int i = 0; while (n[i++] != '0') {} return i - 1; } ''' What is the difference between pass by value and pass by reference? When passing by value, the value passed in a parameter is not changed after the function operations, whilst passing by reference the value does change. Pass by reference: myfunc(& int x){ x+= 5; } int main() { int x = 10; myfunc(x); print(x) } OUTPUT: 15 Pass by value: myfunc(int x){ x+= 5; } int main() { int x = 10; myfunc(x); print(x) } OUTPUT: 10 What is sizeof()? returns the size of either a variable, type or expression allocated in the memory in bytes. What is the function of the linux command "cd"? to change directories and change between file lists What is the function of the linux command "ls"? most commonly used command, lists all folders and files in a particular file path What is the function of the linux command "man"? also known as the manual command, man interfaces the system manual to any given command. What is the function of the linux command "cat"? short for concatenate, concatenate files and print on the standard output What is the function of the linux command "mkdir"? create a directory What is the function of the linux command "chmod"? widely used by admins, sets file permissions on a folder or file What is the function of the linux command "rmdir"? remove a file or directory from a location What is the function of the linux command "touch"? creating, changing, and modifying file timing information What is the function of the linux command "locate"? also known as find command, used to locate a particular file : locate -i final will locate files with the name final What is the function of the linux command "clear"? clears up the command prompt screen What is the function of the linux command "rm"? removes a particular file what is the function of the linux command "mv"? move a file to another directory EX: mv/myfolder/appli/myapps /myfolder/newapp/firstapp what is the function of the linux command "curl"? optionally installed linux package, used to extract info from URLs or IP addresses what is the function of the linux command "echo"? prints specified text in terminal window EX: echo Hello World what is the function of the linux command "free"? displays amount of free and used memory in the system what is the function of the linux command "groups"? display a list of all groups aka groups of users what is the function of the linux command "head"? displays the first 10 lines of a given file EX: head what is the function of the linux command "history"? displays a list of previously used commands what is the function of the linux command "passwd"? changes password EX: sudo passwd yo what is the function of the linux command "ping"? checks network connection and troubleshooting networking issues EX: ping 8.8.8.8 what is the function of the linux command ".alias"? tells the shell to return one string with a different string while performing the commands what is the function of the linux command "ZIP"? confines and packages files EX: $zip what is the function of the linux command "dd"? versatile command used for converting and copying files what is the function of the linux command "chown"? enables users to modify the user and/or group control of an assigned file, directory, or representative link what is the function of the linux command "sudo"? "Super User DO" command, very important, prefix applied to any command that only superusers can execute. lets users operate applications as a different user, by default the root what is the function of the linux command "cal"? displays the current calendar date, can be display different days, entire calendar, julian date etc with various commands what is the function of the linux command "chage"? used by admins to change the expiry data of a user password what is the function of the linux command "df"? retrieves file system data what is the function of the linux command "bc"? command line calculator what is the function of the linux command "uname"? unfolds system data, like operating system, version, processor etc. struct student { string name; int age; char grade; }; student s1, *sptr; sptr = &s1; = "Dakota"; what code would you use to set Dakota's age to 23? sptr->age = 23; What does Amdahl's Law describe? sequential work will limit speedup due to parallelism Is a separate header file to a cpp required? no, although its handy for larger classes int nums[6] = {2, 4, 6, 8, 10, 12}; printArray(nums); void printArray(int n[ ]) { for(int i=0, i<; i++) cout << n[i]; } what will printArray function actually print out? none due to , arrays do not keep track of their own size. would need to use sizeof() int size = sizeof(arr)/sizeof(arr[0]); The fibonacci function is a recursive function. Each time the function gets called in a recursive loop, what type of memory is used to store the contents and state of the program? Stack int A[ ] = {0, 1, 2, 3, 4, 5}; int *ptr = A; How could you print 3 to the screen? cout << ptr[4]; arrays are more or less constant pointers in C++, therefore the above line is legal int x = 10; int y = 20; int z = mystery(x, y); cout << z << "/" << x + y; int mystery(int &a, int b) { a += 15; b += 5; return a + b; } What will print? 50/45 int&a meaning the value of x will change after the function finishes meanwhile y wont. x = 10 + 15 = 25 x+y = 45 int showElement(int A[ ], int index) { cout << A[index]; } What would be equivalent to the cout above? cout << *(A+ index) "A" itself is the address, doing "+ index" moves you to corresponding address in memory "*" dereferences that address so you can get the value of what’s at the address what is another name for cstring? null terminated character array void func(char * ptr) { cout << ptr; } what is the mode of passing used in the function passing parameter ptr? pass by value what is the function of strcmp()? compares two strings character by character, and returns 0 if both strings are equal. int strcmp (const char str1, const char str2); where are strcmp(), strlen() and strcpy() sourced from/defined in? string.h header file; i.e. #include <string.h>

Mostrar más Leer menos
Institución
CECS 325
Grado
CECS 325









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
CECS 325
Grado
CECS 325

Información del documento

Subido en
25 de marzo de 2025
Número de páginas
9
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

CECS 325 Midterm Review Exam (REAL)



What is the first thing you need to do in order to use pthread?
#include <pthread.h>

How would you compile a C++ program with multithreading capabilities in the Linux
Terminal?
c++ program.cpp -lpthread -o program

What is the first parameter in pthread_create?
thread, initialized as pthread_t t1; on a previous line in order to pass information on the
thread through a variable

What is the 2nd parameter in pthread_create?
attribute, not necessary for our class but it's a pointer to a structure that can define
thread attributes such as stack address etc

What should you pass through the 2nd parameter in pthread_create by default?
NULL

What is the 3rd parameter in pthread_create?
the function in which you want to run through the thread, EX: mySort

Do functions in the 3rd parameter of pthread_create include their own parameters?
NO, the 4th parameter of pthread_create includes the function's parameters.

What is the 4th parameter in pthread_create?
arg (arglist), pointer to void that contains the arguments to the function defined in the
earlier argument

What is the function to terminate a thread?
void pthread_exit(void *retval);

What is the function to make a thread wait?
pthread_join(thread1, NULL);

Why is the pthread_join function usually required?
We need to wait till the threads are complete, otherwise the main function will continue
while the threads are processing, risking termination of the program(return 0;) before
the threads are completed.

How do you declare a string in C/C++? (cstring)

, char s[5]; can visualize it as an array with 5 element slots

What should always be included at the end of a C/C++ string? (cstring)
\0, or null pointer

Is char a[4] = ('a', 'b', 'c', 'd') valid? (cstring)
no, assigning 5 characters to a string that has 4 characters. \0 is automatically initialized
as the end of any given string.

What is the strlen() function?
takes a string as its argument and returns the string's length, excluding the \0 at the
end.

'''
int strlen(char n []) {
int i = 0;
while (n[i++] != '\0') {}
return i - 1;
}
'''

What is the difference between pass by value and pass by reference?
When passing by value, the value passed in a parameter is not changed after the
function operations, whilst passing by reference the value does change.

Pass by reference:
myfunc(& int x){ x+= 5; }
int main() { int x = 10; myfunc(x); print(x) }
OUTPUT: 15


Pass by value:
myfunc(int x){ x+= 5; }
int main() { int x = 10; myfunc(x); print(x) }
OUTPUT: 10

What is sizeof()?
returns the size of either a variable, type or expression allocated in the memory in bytes.

What is the function of the linux command "cd"?
to change directories and change between file lists

What is the function of the linux command "ls"?
most commonly used command, lists all folders and files in a particular file path

What is the function of the linux command "man"?
$16.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Bri254 Rasmussen College
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
896
Miembro desde
5 año
Número de seguidores
738
Documentos
3385
Última venta
5 días hace
Best Tutorials, Exam guides, Homework help.

When assignments start weighing you down, take a break. I'm here to create a hassle-free experience by providing up-to-date and recent study materials. Kindly message me if you can't find your tutorial and I will help.

4.0

179 reseñas

5
106
4
20
3
25
2
5
1
23

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes