{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

sample-final-ans

# sample-final-ans - 1(a On a 32-bit machine a variable of...

This preview shows pages 1–3. Sign up to view the full content.

1. (a) On a 32-bit machine, a variable of type float is __4___ bytes in size. (b) On a 32-bit machine, the following struct a is __12___ bytes in size. struct a { int x; double y; }; (c) What is the value of NULL? 0 (d) What C function concatenates one array of characters to the end of another array of characters? strcat 2. The output of the following program is : M E CS Please fill in the blanks : #include<stdio.h> #include<stdlib.h> #include<string.h> struct a{ char as1[2]; char as2[2]; }; struct b{ char bs1; char bs2; char bs3[2]; }; int main(){ ___struct a*___ p1 = malloc(__sizeof(struct a)__); struct b p2; strcpy(p1->as1,strdup("ME")); strcpy(p1->as2,strdup("CS")); memcpy(&___p2___, p1, ___sizeof(struct a)___); p2.bs3[2]='\0'; printf("%c\n", p2.bs1); printf("%c\n", p2.bs2); printf("%s\n", p2.bs3); return 0; } 3. The dot product of two vectors is computed by the following formula: sum {from i=1 to n} a_i * b_i For instance, if a = [1 2 3] b=[4 5 6]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
dotProduct(a,b) = 1*4+2*5+3*6 = 4+10+18 = 32 Complete the following code to compute a dot product */ double dotProduct(double *a, double *b, int n) { int i; double sum; sum = 0; for(i = 0; i < n; i++) sum += __a[i] * b[i]__; return sum; } /* In the numerical methods project, you wrote a program to compute the solution of a linear system Ax = b using the Gauss-Jordan
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

sample-final-ans - 1(a On a 32-bit machine a variable of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online