- Section A Tracing Through A Code 25 Marks 1 Show The Output Produce By Each Of The Following Code Fragments A If 1 (114.26 KiB) Viewed 55 times
Section A: Tracing through a code [25 marks] 1. Show the output produce by each of the following code fragments. (a) If
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Section A: Tracing through a code [25 marks] 1. Show the output produce by each of the following code fragments. (a) If
Section A: Tracing through a code [25 marks] 1. Show the output produce by each of the following code fragments. (a) If we assume that i and j are int variables. [2] i=5; j=3; printf("%d %d", i/j;ij); (b) If we assume that i, j and k are int variables. [2] i=2; j=1;k=0; i *=j *=k; printf("%d %d %d", i,j,k); 2. Supply parentheses to show how C compiler would interpret each of the following expressions. (a) a+b C++e [1] (b) -a-b+c-+d [1] (c) a*-b/c-d [1] [2] 3. Given the following definitions, what is the value of Array[1] [Array[2][0]]? int Array[3] [4] = {{1,2},{6,7}, {17,5,-1,2}}} 4. Given the following function, discover. #include <stdio.h> int discover( int number) /+ process a number +/ { int i =0, j, digits [10]; while (number>=10) { digits[i++]=number10; number /=10; } digits=number; number=0; for(j=0; j<=i; j++) { number=number+((digits [j] 82==0) 20:digits[j]);} return number; (a) What does the execution of discover (1278) return? (b) In general, what does the function discover do? [3] [5]