Quiz 1 Arch
what will print out from the following code: int main() { char arr[] = {1, 2, 3}; char *p = arr; if(&p == &arr) printf("Same"); else printf("Not same"); } Same Not same
what will print out from the following code: int main() { char arr[] = {1, 2, 3}; char *p = arr; if(&p == &arr) printf("Same"); else printf("Not same"); } Same Not same(*)
"x << y" is equivalent to dividing x by 2^y. a) True b) False
"x << y" is equivalent to dividing x by 2^y. a) True b) False(*)
#include <stdio.h> int main(int argc, char **argv) { int b1 = 7, b2 = 11; printf("b1 ^ b2 = %d\n", b1^b2); return 0; } What it the output of the above code? a) b1 ^ b2 = 15 b) b1 ^ b2 = 11 c) b1 ^ b2 = 18 d) b1 ^ b2 = 12
#include <stdio.h> int main(int argc, char **argv) { int b1 = 7, b2 = 11; printf("b1 ^ b2 = %d\n", b1^b2); return 0; } What it the output of the above code? a) b1 ^ b2 = 15 b) b1 ^ b2 = 11 c) b1 ^ b2 = 18 d) b1 ^ b2 = 12 (*)
What will be the output of this code? #include <stdio.h> int main(void) { int a = 12, b = 2; printf("%d",a&b); return 0; } a) 1 b) 14 c) 0 d) 8
#include <stdio.h> int main(void) { int a = 12, b = 2; printf("%d",a&b); return 0; } a) 1 b) 14 c) 0(*) d) 8
Assuming that ptr points to a primitive data type, what is the following equivalent to in regular arithmetic? ptr + i a) (ptr + (i * sizeof(*ptr))) b) (ptr + (i * sizeof(ptr))) c) (ptr + 4) d) (ptr + (i + sizeof(ptr)))
Assuming that ptr points to a primitive data type, what is the following equivalent to in regular arithmetic? ptr + i a) (ptr + (i * sizeof(*ptr))) (*) b) (ptr + (i * sizeof(ptr))) c) (ptr + 4) d) (ptr + (i + sizeof(ptr)))
Char, arrays, pointers, structs, bool, and double are all examples of native data types in C. True False
Char, arrays, pointers, structs, bool, and double are all examples of native data types in C. True False (*)
Consider the following C code snippet: char ch; int i; i = 322; ch = i; What is the value of ch? A) 322 B) 74 C) NULL D) 66
Consider the following C code snippet: char ch; int i; i = 322; ch = i; What is the value of ch? A) 322 B) 74 C) NULL D) 66(*)
Consider the following C program. #include <stdio.h> int main(void) { char c1; char c2; char *p; c1 = 'a'; p = &c1; c2 = c1; *p = 'b'; c2 = 'c'; printf("%c\n", c1); } What is the output of this program? a b c
Consider the following C program. #include <stdio.h> int main(void) { char c1; char c2; char *p; c1 = 'a'; p = &c1; c2 = c1; *p = 'b'; c2 = 'c'; printf("%c\n", c1); } What is the output of this program? a b (*) c
Consider the following code snippets. Which correctly results in p pointing to the integer value 13 in memory? a) int* p; int i=10; p=&i; p*=13; b) int* p; p*=13; c) int* p; int i=10; p=&i; p=p+3; a b c
Consider the following code snippets. Which correctly results in p pointing to the integer value 13 in memory? a) int* p; int i=10; p=&i; p*=13; b) int* p; p*=13; c) int* p; int i=10; p=&i; p=p+3; a (*) b c
Consider the following program, what is the output? #include <stdio.h> int main(int argc, char **argv) { int a = 0, b = 0, c = 0; int x = a++ || ++b || --c; printf("a+b+c=%d x=%d\n", a + b + c, x); return 0; } a+b+c=0 x=1 a+b+c=1 x=1 a+b+c=2 x=1 a+b+c=1 x=0
Consider the following program, what is the output? #include <stdio.h> int main(int argc, char **argv) { int a = 0, b = 0, c = 0; int x = a++ || ++b || --c; printf("a+b+c=%d x=%d\n", a + b + c, x); return 0; } a+b+c=0 x=1 a+b+c=1 x=1 a+b+c=2 x=1 (*) a+b+c=1 x=0
Consider this code block: char c = '4'; int y; What is is proper conversion from '4' (char c) to 4 (y = 4)? A) y = (int) (c + '0'); B) y = int (c + '0'); C) y = (int) (c - '0'); D) y = int (c - '0');
Consider this code block: char c = '4'; int y; What is is proper conversion from '4' (char c) to 4 (y = 4)? A) y = (int) (c + '0'); B) y = int (c + '0'); C) y = (int) (c - '0'); (*) D) y = int (c - '0');
Generally speaking, which of the following two data types in C will differ when compiled using a 32bit vs 64bit compiler? a)int and float b)int and pointer c)int and long d)long and pointer
Generally speaking, which of the following two data types in C will differ when compiled using a 32bit vs 64bit compiler? a)int and float b)int and pointer c)int and long d)long and pointer (*)
Given the following code, determine the final value of p : int *p; p = (int *) 200; p = p + 4; A) 204 B) 201 C) 216
Given the following code, determine the final value of p : int *p; p = (int *) 200; p = p + 4; A) 204 B) 201 C) 216 (*)
How many bits in a byte? a. 1 b. 4 c. 9 d. 8
How many bits in a byte? a. 1 b. 4 c. 9 d. 8 (*)
In C, the programmer is responsible for deallocated all unused heap allocated memory with the free() function. True False
In C, the programmer is responsible for deallocated all unused heap allocated memory with the free() function. True (*) False
Signed is 0 to 255, unsigned is -128 to 127. True False
Signed is 0 to 255, unsigned is -128 to 127. True False (*)
The #include directive is processed by: The C compiler The C preprocessor The Linux shell None of the above
The #include directive is processed by: The C compiler The C preprocessor (*) The Linux shell None of the above
The output of the following code is given below. Which missing line would generate this output? #include <stdio.h> int main(){ char str[] = "HelloWorld"; char *ptr; //---------- MISSING LINE printf("The value of 'ptr' is: %c", *ptr); } OUTPUT: The value of 'ptr' is: W a) ptr = ptr + 5; b) ptr = str[5]; c) ptr = &str[5];
The output of the following code is given below. Which missing line would generate this output? #include <stdio.h> int main(){ char str[] = "HelloWorld"; char *ptr; //---------- MISSING LINE printf("The value of 'ptr' is: %c", *ptr); } OUTPUT: The value of 'ptr' is: W a) ptr = ptr + 5; b) ptr = str[5]; c) ptr = &str[5]; (*)
The size of a struct in C is always exactly the number of bytes needed to store all the members of the struct. True False
The size of a struct in C is always exactly the number of bytes needed to store all the members of the struct. True False (*)
Topic: Int Size On the Raspberry Pi running Raspbian in 32-bit mode, how many bytes are in an int? 1 8 4 2
Topic: Int Size On the Raspberry Pi running Raspbian in 32-bit mode, how many bytes are in an int? 1 8 4 (*) 2
True or False, would (1.0/3 + 1/3.0 + 1.0/3.0) == 1 return true (a non-zero value in C)? (a) true (b) false
True or False, would (1.0/3 + 1/3.0 + 1.0/3.0) == 1 return true (a non-zero value in C)? (a) true (b) false (*)
True or False: To view the Raspberry Pi configuration menu in your terminal window, type the command $ sudo rpi-config into the command line of the Raspberry Pi. True False
True or False: To view the Raspberry Pi configuration menu in your terminal window, type the command $ sudo rpi-config into the command line of the Raspberry Pi. True False (*)
True or false: By declaring a pointer you allocate space for the pointer and the pointee. True False
True or false: By declaring a pointer you allocate space for the pointer and the pointee. True False (*)
True/False? If a C program executes on your laptop's host OS and processor, simply sharing the executable file will allow you to run the code on your pi. A.) True, but only for machines that have the same OS B.) False
True/False? If a C program executes on your laptop's host OS and processor, simply sharing the executable file will allow you to run the code on your pi. A.) True, but only for machines that have the same OS B.) False (*)
Using Internet Sharing, where does the Raspberry Pi get it's IP address from: a) The WiFi router b) Rasbian Linux c) The host OS on your laptop d) None of the Above
Using Internet Sharing, where does the Raspberry Pi get it's IP address from: a) The WiFi router b) Rasbian Linux c) The host OS on your laptop (*) d) None of the Above
We know that int a, b, c, *d=&c, and which of the following statement can be used to ask the value of variable a, b and c from the user? A. scanf("%d%d%d", &a, &b, d) B. scanf("%d%d%d", a, b, d); C. scanf("%d%d%d", &a, &b, &d); D. scanf("%d%d%d", a, b,*d);
We know that int a, b, c, *d=&c, and which of the following statement can be used to ask the value of variable a, b and c from the user? A. scanf("%d%d%d", &a, &b, d) (*) B. scanf("%d%d%d", a, b, d); C. scanf("%d%d%d", &a, &b, &d); D. scanf("%d%d%d", a, b,*d);
What is the 2s complement representation of -5? a.) 0101 b.) 1010 c.) 1011 d.) 1112
What is the 2s complement representation of -5? a.) 0101 b.) 1010 c.) 1011 (*) d.) 1112
What is the binary code for -55 on an 8 bit int? a. 11001001 b. 00110111 c. 10101101 d. 11001101
What is the binary code for -55 on an 8 bit int? a. 11001001 (*) b. 00110111 c. 10101101 d. 11001101
What is the correct output #include <stdio.h> int main() { float c = 5.0; printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32); return 0; } The temperature in Fahrenheit is 41.00 The temperature in Fahrenheit is 23.00 The temperature in Fahrenheit is 37.00 Compiler error
What is the correct output #include <stdio.h> int main() { float c = 5.0; printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32); return 0; } The temperature in Fahrenheit is 41.00 The temperature in Fahrenheit is 23.00 The temperature in Fahrenheit is 37.00 (*) Compiler error
What is the correct output of this code? #include void main() { char s[] = "C++"; printf("%s ",s); s++; printf("%s",s); } A : C++ C++ B : C++ ++ C : ++ ++ D : Compile error
What is the correct output of this code? #include void main() { char s[] = "C++"; printf("%s ",s); s++; printf("%s",s); } A : C++ C++ B : C++ ++ C : ++ ++ D : Compile error (*)
What is the default floating point type in c? float double int long double
What is the default floating point type in c? float double (*) int long double
What is the output of the following code? #include <stdio.h> struct many_numbers { int a, b, c; } int main() { struct many_numbers nums = {.a = 1, .b = 2, .c = 3}; int* pointer = &nums.a; pointer = pointer + 1; printf("%d\n", *pointer) } a) 1 b) 2 c) 3 d) None of the above
What is the output of the following code? #include <stdio.h> struct many_numbers { int a, b, c; } int main() { struct many_numbers nums = {.a = 1, .b = 2, .c = 3}; int* pointer = &nums.a; pointer = pointer + 1; printf("%d\n", *pointer) } a) 1 b) 2 (*) c) 3 d) None of the above
What is the output of the following program? #include <stdio.h> void func1(int arr[]) { printf("%d\n", sizeof(arr)/sizeof(int)); } int main(int argc, char **argv) { int arr[] = {1, 2, 3, 4, 5, 6}; printf("%d ", sizeof(arr)/sizeof(int)); func1(arr); return 0; } a. 6 6 b. 6 1 c. 1 1 d. 1 6
What is the output of the following program? #include <stdio.h> void func1(int arr[]) { printf("%d\n", sizeof(arr)/sizeof(int)); } int main(int argc, char **argv) { int arr[] = {1, 2, 3, 4, 5, 6}; printf("%d ", sizeof(arr)/sizeof(int)); func1(arr); return 0; } a. 6 6 b. 6 1 (*) c. 1 1 d. 1 6
What is the output of this code? #include <stdio.h> int main(int argc, char *argv[]) { int x[] = {1, 12, 30, 8}; printf("%d\n", *(x + 2)); return 0; } a) 3 b) 30 c) 1 d) 8
What is the output of this code? #include <stdio.h> int main(int argc, char *argv[]) { int x[] = {1, 12, 30, 8}; printf("%d\n", *(x + 2)); return 0; } a) 3 b) 30 (*) c) 1 d) 8
What is the output of this code? #include <stdio.h> void foo(int *ptr) { *ptr = 12; } int main(void) { int x = 4; foo(&x); printf("%d", x); return 0; } a. 4 b. 12 c. This program won't compile
What is the output of this code? #include <stdio.h> void foo(int *ptr) { *ptr = 12; } int main(void) { int x = 4; foo(&x); printf("%d", x); return 0; } a. 4 b. 12 (*) c. This program won't compile
What type of processor do the Raspberry Pis we use have? a) x86 b) x64 c) arm d) leg
What type of processor do the Raspberry Pis we use have? a) x86 b) x64 c) arm (*) d) leg
What type of value does sizeof return? A. Short B. Char C. Unsigned int D. Long
What type of value does sizeof return? A. Short B. Char C. Unsigned int (*) D. Long
When integral types are mixed together in arithmetic expressions, how does the compiler deal with different widths present? (Ex. ('b' + 5)) A. Promotes the smaller type to be the same size as the larger type B. Demotes the larger type to be the same size as the smaller type C. Find a type with a size in the midpoint of the two types and convert each type by promoting the smaller type and demoting the larger type
When integral types are mixed together in arithmetic expressions, how does the compiler deal with different widths present? (Ex. ('b' + 5)) A. Promotes the smaller type to be the same size as the larger type (*) B. Demotes the larger type to be the same size as the smaller type C. Find a type with a size in the midpoint of the two types and convert each type by promoting the smaller type and demoting the larger type
malloc() initializes each block of memory to the default value of '0'. True False
malloc() initializes each block of memory to the default value of '0'. True False (*)
struct fraction { int numerator; int denominator; }; struct fraction f1, f2; //declare two fractions f1.numerator = 22; f1.denominator = 7; f2 = f1; True or False: f2.numerator = 22, f2.denominator = 7 True False
struct fraction { int numerator; int denominator; }; struct fraction f1, f2; //declare two fractions f1.numerator = 22; f1.denominator = 7; f2 = f1; True or False: f2.numerator = 22, f2.denominator = 7 True(*) False