1.
Assuming our label 'a' is to be an array of 32bit integers, the following code creates an array of how many elements?
.data .balign 4 a: .skip 600
150 |
140 |
75 |
300 |
None of the above 2. Assuming the variables: x, y, and z are already defined as integers with x=6, y=4, and z=12, which of the following printf statements written in C/C++ will correctly output the following to the terminal screen: Point(6,4,12)
|
1. 150
balign advances the location counter to 4's multiple. Hence 600/4 = 150
2.
printf("Point(%d,%d,%d)",x,y,z); |
While using printf(), we should first use the format specifier, here %d then use variable to print.
1. Assuming our label 'a' is to be an array of 32bit integers, the following code...
Use the following code, which initializes an array x with 1000 random integers, to answer the questions a and b. java.util.Random generator = new java.util.Random( );//accessing Random class final int MAX = 1000; int[] x = new int[MAX]; for( int j = 0; j < MAX; j++ ) { x[j] = generator.nextInt( MAX ) + 1; } a. Write partial code to print all array elements of x in reverse order (one array element per line) b. Write partial code...
What is wrong with the following code that prints out the elements of a 2x3 array? for (int i 0; i < 3; ++i) { for (int j = 0; j < 2: ++j) { printf("x(%d] [%d] ". %.2f\n", i, j, x[i][j]); O Expression ali]li] is incorrect O There is nothing wrong with the code 0 %2t is invalid O It is printing for a 3x2 array
need question 3 assap using cin and cout outputs please Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Display both arrays x and y in a table with labeled column headings. 0 y- 2x+1 2) 120 pts] Consider the following 2D array. 01 2 -1 X-3 5 0 6 -3 7 -15 Use the standard notation and obtain the following (a) Create and display array...
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
C Programming 1 point Given the following code, if Static() is called twice, what will be printed to the screen from the second call? int x = 10; void Print(int x) printf("%d", x); } { void Output() { printf("%d", x); > void Static) { static int x = 0; printf("%d", x++); } Type your answer 8 1 point Given the following code, if Static() is called, what will be printed to the screen? int x = 10; void Print(int x)...
Assuming x and y each are a list of integers, answer the following questions. Use a as a running variable. If necessary use b as an additional running variable. Do not use any other variables as you do not need. a. Write a Python statement using lambda calculus map to map x to y where every element of y is incremented by 1. b. Write a Python statement using lambda calculus reduce to reduce x to s, where s is...
1. Given the following array, what is the value of pets[3]? var pets = new Array("giraffe", "pig", "beetle", "hamster", "spider", "goldfish", "cow"); A. pig B. beetle C. hamster D. spider 2. Given the following array, which statement will create a variable named product that multiplies 4 * 5, using array elements? var nums = new Array(2, 3, 4, 5, 6, 30, 40, 50, 60); A. var product = nums[1] * nums[2]; B. var product = nums[2] * nums[3]; C. var...
Can someone explain these three questions for me? Thanks. Answers are provided Use the code segment below for problems 6-7 int x = 1; int y - 0 int z 1: if(! (x && y) ) x 0; İf ( ! (x 11 y) ) y+= (x + y) % 2 == 0 ? 1 : 0; printf ("Total #1 : %d\n", x + y + z); printf ("Total #2: %d\n", !x + !y + !2); 6. Which of the...
(a) Write a C program to print a list of all integers between 1 and 1,000 (inclusive) which are divisible by 7 but not by 13. The list should be printed to a file called "output.dat". Remember to close the file after use. (35%) (b) Explain what is meant by the C preprocessor. Explain the effect of the following line of code: #define SQUARE (x) (x) * (x) (25%) (c) Explain the concept of an array in C. Write down...
1. What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; } A. 90 B. 110 C. 210 D. This is an infinite loop 2. If a superclass has constructor(s): A. then its subclass must initialize the superclass fields (attributes). B. then its subclass must call one of the constructors that the superclass does have. C. then its subclass does not inherit...