Шукаєте відповіді та рішення тестів для Course 31709? Перегляньте нашу велику колекцію перевірених відповідей для Course 31709 в lms.aub.edu.lb.
Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!
#include‹stdio.h›
int main()
{
struct site
{
char name[] = "GeeksQuiz";
int no_of_pages = 200;
};
struct site *ptr;
printf("%d ", ptr->no_of_pages);
printf("%s", ptr->name);
getchar();
return 0;
}
Choose the correct output:
union test
{
int x;
char arr[8];
int y;
};
int main()
{
printf("%d", sizeof(union test));
return 0;
}
Assume int = 4 bytes, char = 1 byte, no alignment.
struct node
{
int i;
float j;
};
struct node *s[10];
The above C declaration define 's' to be
int main()
{
char *s1 = (char *)malloc(50);
char *s2 = (char *)malloc(50);
strcpy(s1, "Geeks");
strcpy(s2, "Quiz");
strcat(s1, s2);
printf("%s", s1);
return 0;
}
Output of following C program? Assume that all necessary header files are included
Consider the following C program:
#include <stdio.h>
void fun1(char *s1, char *s2) {
char *temp;
temp = s1;
s1 = s2;
s2 = temp;
}
void fun2(char **s1, char **s2) {
char *temp;
temp = *s1;
*s1 = *s2;
*s2 = temp;
}
int main() {
char *str1 = "Hi", *str2 = "Bye";
fun1(str1, str2);
printf("%s %s", str1, str2);
fun2(&str1, &str2);
printf("%s %s", str1, str2);
return 0;
}
The output of the program above is:
struct {
short s[5];
union {
float y;
long z;
}u;
} t;
Assume short = 2 bytes, float = 4 bytes, long = 8 bytes. Ignoring alignment, what is the memory requirement for t?
Doubly Linked List
In this exercise you will implement a generic doubly linked list in C.
Each node in the list contains a pointer to a payload (of type void *), a pointer to the next node, and a pointer to the previous node.
The list itself keeps track of its head, its tail, and the number of elements currently stored.
You should write your code in multiple files:
You’ll have to implement the below functions (Note that the LinkedList is Dynamically allocated):
To demonstrate how LL_Display can be used, you will provide two printing functions that match the required function pointer type (printInt and printString). These functions can be passed to LL_Display depending on the type of data stored in the list.
Compile the code on a Linux VM. Show screenshots of the compilation process and run the application (if you weren't able to paste thes screenshots here, send the to our TA Mr Joseph Samara (jfs22)).
The payloads that will be stored in the linked list are taken as command line arguments. The second command line argument represents the type of data that will be stored in the linked list (either int or string).
Note that in case of int, the command line arguments must be converted to integers (possibly using the atoi function).
Examples of running the application
./app int 33 45 21 89 100 2
./app string hi hello cmps241 systems programming
All memory you allocate must be freed.
#include<stdio.h>
struct st
{
int x;
struct st next;
};
int main()
{
struct st temp;
temp.x = 10;
temp.next = temp;
printf("%d", temp.next.x);
return 0;
}
Choose the correct output from the options given below:
Consider the following C functions.
int tob (int b, int* arr) {
int i;
for (i = 0; b>0; i++) {
if (b%2) arr [i] = 1;
else arr[i] = 0;
b = b/2;
}
return (i);
}
int pp(int a, int b) {
int arr[20];
int i, tot = 1, ex, len;
ex = a;
len = tob(b, arr);
for (i=0; i<len ; i++) {
if (arr[i] ==1)
tot = tot * ex;
ex= ex*ex;
}
return (tot) ;
}
The value returned by pp(3,4) is ________ .
What happens if you forget to free memory allocated with malloc()?