b) The body of a do-while loop is always executed at least once.
c) If p points to the array element a[j], then p + i points to a[i+j].
d) Any number of pointer variables may point to the same object.
struct Point
{
int x, y;
};
struct Line
{
Point a, b;
};
Line image[10];
b) image[6] is an struct
c) image[6].a is a array
d) image[6].a.x is a struct
7. Multiple choice problems: (5 x 2 = 10 pts)
|
||||||||
|
#include<stdio.h> int main() { int i=10; int *j=&i; return 0; } |
||||||||
|
float scores[20];
A. 20 B. 76 C. 80 D. 84 E. None of the above
A. 0 B. 0.5 C. 0.25 D. -0.25 E. None of the above
prod = 1;
for (count = 3; count < 6; count++)
prod *= count;
A. 3 B. 60 C. 120 D. 360 E. 840
Can someone please answer the following questions. The language is C/C++. I rate if the answers are correct. Thank you in advance
7)
I) OPTION B IS CORRECT
iI) OPTION C IS CORRECT
Iii) OPTION C IS CORRECT
Iv) OPTION A IS CORRECT
v) OPTION B IS CORRECT
State true or false: (6 x 2 = 12 pts) Using -- with a reverse iterator...
2. Give the minimum size of each of the following C++ types, assuming that char values occupy one byte, short values occupy two bytes, int and float values occupy four bytes, double and long values occupy eight bytes, and pointers occupy four bytes. a) union u type ( double a[3]; int *b; char c[10] b) struct s1type float *d [2]; long e[4] char f[6] short *gi c) struct s2 type ( s1_type s; u type u [2]; int *h[3]; short...
C language not C++ 1. Write the statements to do the following: (2 pts) a. Define a struct with member variables width, height, topleft x, topleft y all floats). Use a tag to call it Rectangle. b. Declare a variable struct type Rectangle 2. Consider the following variables: struct int x; float y; char zi var1; union nt x; float y; char[20] z;) var2 f float and int are stored using 4 bytes each, what is the size (in bytes)...
#include <stdio.h> int main(int argc, char *argv[]) { char a, *pc, c[9]; int i, *pk, k[9]; a='z'; pc=&(c[8]); pk=&(k[0]); for (i=0; i<9; i++) { *pc=a-(char)i; pc--; *pk=(int)a-i; pk++; } return 0; }//end of main Answer the below questions with the above code Write out the memory map for the above C code in the following table. For array variables, list the address range for the entire array. Assume the memory address starts from 100, that is, the address for a...
Question 11 pts Fill in the blank. Two functions are defined main.c and MyAge.c // FILE main.c main ( ) { _______ int age ; printf ( " the value of age is %d \n", age ) ; } // FILE MyAge.c int age = 10; int MyAge ( ) { } Group of answer choices static external internal extern Flag this Question Question 21 pts Fill in the blank. Two functions are defined main.c and MyAge.c The below program...
C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array named f, and one double array named d, each of size M. (b)Declare array x with N of those structs. (c)Write a void function to traverse array x (using a pointer) assigning to each element in each array d (in each struct in array x) the sum of the corresponding elements in arrays i and f (in the same struct). Use 3 pointers (of...
Please answer problem #5 thank you str.c #include "str.h" #include <stdio.h> int str_len(char *s) { /* this is here so code compiles */ return 0; } /* array version */ /* concantenate t to the end of s; s must be big enough */ void str_cat(char s[], char t[]) { int i, j; i = j = 0; while (s[i] != '\0') /* find end of s */ i++; while ((s[i++] = t[j++]) != '\0') /* copy t */ ;...
I need help on this Systems review please! it's due by midnight monday. Question 1 Not yet answered Points out of 1.00 Flag question Question text Using these declarations: int * numberPointers[3]; int * pointer; int number; Which of the following statements would generate a warning or error? Select one: a. number = pointer; b. *pointer = number; c. pointer = numberPointers; d. numberPointers[2] = &number; e. a., b., and d. f. a. and c. Question 2 Not yet answered...
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...
Consider a C function negMat(), that negates each element of a K x K matrix y[][], and stores each result into the matrix x[][] : void negMat(float *x, float *y, int K) { int i, j; for (i=0; i<K; i++) { for (j=0; j<K; j++) { x[i * K + j] = - y[i * K + j]; } } } negMat() runs on the CPU (obviously), and x[][]and y[][] are stored in row-major order. Write a CUDA kernel negMatGPU(),...
Learn the example C program in Folio consisting of three files (a.c, a.h, main.c) and complete this exercise. You need to understand function, pointer and the selection sort algorithm. Write a C program that consists of three files mysort.h, mysort.c and myMain.c. Below is the mysort.h prototype #include <stdlib.h> #include <stdio.h> void generateNums(int *myarr, int len); void sortNums(int *myarr, int len); mysort.h must contain only the function declarations (prototypes) listed above generateNums function should generate len random integers in the...