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...
QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2, 3}; int *p = a; int **r = &p; printf("%p %p", *r, a); A. Different memory addresses printed B. 1 2 C. Same memory address printed twice D. 1 1 2 points QUESTION 10 What will be the output of following code snippet? int arr[4] = {1, 2, 3, 4}; int *p; p = arr + 3; *p = 5; printf("%d\n", arr[3]); A....
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 */
;...
14) Given: int grade[4]; grade and &grade[0] can be interchangeable. True False 15) char val[3]; char *ptr; ptr = &val[2]; a. will assign the value in val[2] to the pointer b. will assign the address of val[2] to the pointer c. results both a and b d. none 16) In C++, you declare a pointer variable by using the ____ symbol. a. @ b. * c. # d. & 17) Which of the following correctly declares...
QUESTION 6 What is the output of following C code? struct numbers { int x = 2; int y = 3; } int main() { struct numbers nums; nums.x = 110; nums.y = 100; printf("%d\n%d", nums.x, nums.y); return 0; } A. Compile-time Error B. 110 100 C. 2 3 D. Run-time Error 2 points QUESTION 7 What is the output of following C code? typedef struct student { char *stud; }s1; int main() { s1 s; s.stud...
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(),...