Section A: Tracing through a code [25 marks] 1. Show the output produce by each of the following code fragments. (a) If

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post by answerhappygod »

Section A Tracing Through A Code 25 Marks 1 Show The Output Produce By Each Of The Following Code Fragments A If 1
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 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]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply