Menu

Exercise Covers Pointers Arrays 2d Arrays Try Solve Following Exercise Without Using Compi Q43895280

This exercise covers pointers, arrays and 2D arrays. Try to solve the following exercise without using any compiler. Pointers(d) int main() float a - 13.5; float b, C: b &a ; /* suppose address of a is 1006 / printf (n Xu Xu, &a, b, c printf (int main() int at ] { 2, 4, 6, 8, 10); int i; change (a, 5); for (i ; i < 4 ; i++ ) printf(n , a[1]); return ; void change4.What would be the output of the following programs: (a) int main() int n[3][3] = { 2, 4, 3, 6, 8, 5, 3, 5, 1}; printf (n%5.) Match the following with reference (1 to 10) to the following segment (a to m): int x[3][5] = { { 1, 2, 3, 4, 5 }, { 6, 7This exercise covers pointers, arrays and 2D arrays. Try to solve the following exercise without using any compiler. Pointers 1. What would be the output of the following programs: (a) int main() int i = 5, j = 2; junk (i, j); printf (“n%d %d”, i, j); return ; void junk ( int i, int j) i = i* i; j – j*j; (6) int main() int i = 5, j = 2; junk (&i, &j) ; printf (“n%d %d”, i, j); return ; void junk (int *i, int *j) *i = “i * = *j ‘i; j; int main() int i = 4, j = 2; junk (&i, j); printf (“n%d %d”, i, return ; j) ; void junk (int *i, int 😉 jj*j; (d) int main() float a – 13.5; float “b, “C: b &a ; /* suppose address of a is 1006 / printf (“n Xu Xu”, &a, b, c printf (“n&F XF XF XF XF”, a, return 0; ) ; (a), *8a, b, c ); 2.)Point out the errors, if any, in the following programs: (a) int main() int i – 135, a. 135, k ; k -pass (i, a ) printf (“nad”, k); return e: int pass (int j, int b) int cu return (C): int main() int p – 23, f. 24; jiaayo (&p, 8 ) printf (“n%d %d”, P. f); return : void jiaayjo ( inta, int ) 999: (c) int main() int K-35, 2; 2. check (K); printf (“nad”, 2); return ; int check (m) int : if ( > 40 ) return ( 1); else return(0); int main() int at ] { 2, 4, 6, 8, 10); int i; change (a, 5); for (i ; i < 4 ; i++ ) printf(“n “, a[1]); return ; void change (int *b, int n) int i; for ( 1. ( <n ;i 1) + ; i++ (b ) ). S : int main() int a[5], 1, b. 15; for (i- ;i< 5; i++) a[1] – 2 .1 ; + ( a,b ) ; for(i i < 5 ; i++ ) printf (“n “, ali]); printf(“n “, b ); void f int *x, int y ) int i; for ( i= 0 (X . ) ; i< 5 2 : ; i++ ) int main() static int a[5]; Int : for ( i i i – 4 ; i++ printf (“n “, a[1]); return e: ) int main() int a[] – ( 5, 1, 15, 20, 25 }; int i, 1.k-1. +a(1) j = a[1]++; ali+l printf (“nAdd Xd”, 1, ); return e: 4.What would be the output of the following programs: (a) int main() int n[3][3] = { 2, 4, 3, 6, 8, 5, 3, 5, 1}; printf (“n%d %d %d”, *n, n[3][3], n[2][2]); return; (b) main() int n[3][3] = { 2, 4, 3, 6, 8, 5, 3, 5, 1 }; int i, *ptr ; ptr = n; for (i = 0; i <= 8; i++) printf (“n%d”, *( ptr + i)); (c) int main() { int n[3][3] = { 2, 4, 3, 6, 8, 5, 3, 5, 1}; int i, j; for (i = 0; i <= 2; i++) for (j = 0; j <= 2; j++) printf (“n%d %d”, n[i][j], *( *(n + i) +j)); return 5.) Match the following with reference (1 to 10) to the following segment (a to m): int x[3][5] = { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 }, { 11, 12, 13, 14, 15} int *n = x; OVOCAWN- “(“(x + 2) + 1) *T*x + 2) + 5 *(*(x + 1)) *( (x) + 2) + 1 * (*(x + 1) + 3 ) ‘n *(n +2 ) (“(n + 3 ) + 1 “(n + 5)+1 ++’n mooooc XE on OVANW A CO 6. If you want to store an array of 5 strings with the maximum length of a string is 100, how would you declare it? Answer: 7. Given a 2D array. Write a function that will take the 2D array as argument and then print the maximum value in each row of that 2D array. Also, write a line to show how would you call that function. Do not write the main function. Show transcribed image text This exercise covers pointers, arrays and 2D arrays. Try to solve the following exercise without using any compiler. Pointers 1. What would be the output of the following programs: (a) int main() int i = 5, j = 2; junk (i, j); printf (“n%d %d”, i, j); return ; void junk ( int i, int j) i = i* i; j – j*j; (6) int main() int i = 5, j = 2; junk (&i, &j) ; printf (“n%d %d”, i, j); return ; void junk (int *i, int *j) *i = “i * = *j ‘i; j; int main() int i = 4, j = 2; junk (&i, j); printf (“n%d %d”, i, return ; j) ; void junk (int *i, int 😉 jj*j;
(d) int main() float a – 13.5; float “b, “C: b &a ; /* suppose address of a is 1006 / printf (“n Xu Xu”, &a, b, c printf (“n&F XF XF XF XF”, a, return 0; ) ; (a), *8a, b, c ); 2.)Point out the errors, if any, in the following programs: (a) int main() int i – 135, a. 135, k ; k -pass (i, a ) printf (“nad”, k); return e: int pass (int j, int b) int cu return (C): int main() int p – 23, f. 24; jiaayo (&p, 8 ) printf (“n%d %d”, P. f); return : void jiaayjo ( inta, int ) 999: (c) int main() int K-35, 2; 2. check (K); printf (“nad”, 2); return ; int check (m) int : if ( > 40 ) return ( 1); else return(0);
int main() int at ] { 2, 4, 6, 8, 10); int i; change (a, 5); for (i ; i

Expert Answer


Answer to This exercise covers pointers, arrays and 2D arrays. Try to solve the following exercise without using any compiler. Poi…

OR