5. Write the output for the following codes No Code Snippet a. b. int a[] =...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
5. Write the output for the following codes No Code Snippet a. b. int a[] = new int[5]; int i; No C. a[1] = 10; a[3] = 50; a[0] = a[3] / a[1]; a[4] = a[1 + 1] - a[4 - 1] + a[2]; a[2]++; for(i = 0; i < 5; i++) OBJECT ORIENTED PROGRAMMING PROGRAMMING System.out.printf("%d", a[i]); int[] a = {0, 2, 4, 1, 3}; for (int i = 0; i < a.length; i++) a[i] = a[(a[i] + 3) % a.length]; System.out.println(a[0] + a[1] + a[2] + " int[] a {10, 20, 30}; fix1(a[1]); fix(a); Code Snippet System.out.println(a[1] + a[1]); public static int fix1(int a){ a = a + 10; return a; public static void fix(int[] a){ a[1] = a[1] * 10; " " + a[3] + a[4]); Output [1 Marks] Output Page 3 of 9 CS102_ [1 Marks] [1 Marks] d. double [][] a = new double [3] [3]; for(int i = 0; i < 3; i++){ e. for(int j = 0; j < 3; j++){ a[i][j] = i + j; if(j == 1) } for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ } break; } System.out.printf("%.2f ", a[i][j]); OBJECT ORIENTED PROGRAMMING PROGRAMMING System.out.println(); ArrayList items = new ArrayList (); int j = 0; for(int i = 0; i < 3; i++){ items.add(j); j+= 4; items.remove((Integer) 4); items.add(1, 10); for(Integer i : items) System.out.print(i + "); [1 Marks] Page 4 of 9 CS102 [1 Marks] 5. Write the output for the following codes No Code Snippet a. b. int a[] = new int[5]; int i; No C. a[1] = 10; a[3] = 50; a[0] = a[3] / a[1]; a[4] = a[1 + 1] - a[4 - 1] + a[2]; a[2]++; for(i = 0; i < 5; i++) OBJECT ORIENTED PROGRAMMING PROGRAMMING System.out.printf("%d", a[i]); int[] a = {0, 2, 4, 1, 3}; for (int i = 0; i < a.length; i++) a[i] = a[(a[i] + 3) % a.length]; System.out.println(a[0] + a[1] + a[2] + " int[] a {10, 20, 30}; fix1(a[1]); fix(a); Code Snippet System.out.println(a[1] + a[1]); public static int fix1(int a){ a = a + 10; return a; public static void fix(int[] a){ a[1] = a[1] * 10; " " + a[3] + a[4]); Output [1 Marks] Output Page 3 of 9 CS102_ [1 Marks] [1 Marks] d. double [][] a = new double [3] [3]; for(int i = 0; i < 3; i++){ e. for(int j = 0; j < 3; j++){ a[i][j] = i + j; if(j == 1) } for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ } break; } System.out.printf("%.2f ", a[i][j]); OBJECT ORIENTED PROGRAMMING PROGRAMMING System.out.println(); ArrayList items = new ArrayList (); int j = 0; for(int i = 0; i < 3; i++){ items.add(j); j+= 4; items.remove((Integer) 4); items.add(1, 10); for(Integer i : items) System.out.print(i + "); [1 Marks] Page 4 of 9 CS102 [1 Marks]
Expert Answer:
Answer rating: 100% (QA)
1 Output 0 10 1 50 39 Explanation Initially all elements in the array a are 0 a1 is assigned the value 10 a3 is assigned the value 50 a0 is assigned the result of the expression a3a1 which is 5 a4 is ... View the full answer
Related Book For
Posted Date:
Students also viewed these electrical engineering questions
-
Describe the output for the following sequence of deque operations: insertFront(3), insertBack(8), insertBack(9), insertFront(5), removeFront(), eraseBack(), first(), insertBack(7), removeFront(),...
-
Describe the output for the following sequence of queue operations: enqueue(5), enqueue(3), dequeue(), enqueue(2), enqueue(8), dequeue(), dequeue(), enqueue(9), enqueue(1), dequeue(), enqueue(7),...
-
Write a research paper on History of Object Oriented Databases
-
R. Bright, an electrical goods wholesaler, has three departments: (a) Music, (b) TV and (c) Kitchen. The following is a summary of Brights sales invoices during the week 1 to 7 February 2013. (a)...
-
Labear Corporation earned revenues of $41 million during 2011 and ended the year with net income of $5 million. During 2011, Labear collected $23 million from customers and paid cash for all of its...
-
Find the domain of the function. g(x) = 1/1 tan x
-
Advantage Advertising, Inc., engaged in the following business transactions during November of 2010: Advantage Advertising, Inc., uses the following accounts: Cash, Accounts Receivable, Supplies,...
-
The following data are the actual results for Marvelous Marshmallow Company for August. Actual output.............................................................13,500 cases Actual variable...
-
4. Santiago and Lucia started to live together as common-law husband and wife in 2000. In the course of their relationship, they acquired several properties which included a 600-square meter house...
-
A. Create a budget (using the Budget tab in the Final Project Workbook) based on your second year of operations. [ACC-325-01] B. Summarize your budget and make suggestions for the future of your...
-
Your team have just been assigned to a major project in its capital budgeting division. This assignment requires your team to determine the net cash flows and Net Present Value (NPV), Internal Rate...
-
Point B is located across the river from point Aand at a 4 2 . 0 angle upstream from A A boat travels from point A to point B sailing at 1 7 . 0 km / h relative to the water. The current in the...
-
Fast Ltd manufactures specialised moulding machinery for both sale and lease. On 1 July 2023, Fast Ltd leased a machine to Furious Ltd. The machine being leased cost Fast Ltd $235 000 to make and its...
-
The Effects of Transformational and Transactional Leadership on Quality Improvement. Laohavichien, Tipparat; Fredendall, Lawrence D; Cantrell, R Stephen. Abstract: This article furthers the...
-
Bramble Corporation purchased from its stockholders 4,200 shares of its own previously issued stock for $214,200. It later resold 1,680 shares for $54 per share, then 1,680 more shares for $49 per...
-
Waller Co. paid a $0.142 dividend per share in 2000, which grew to $0.300 in 2012. This growth is expected to continue. What is the value of this stock at the beginning of 2013 when the required...
-
How could not having a strategy hurt a brand on social media? What are some content ideas for those who are at the "Awareness" stage of the sales funnel? What does it mean to A/B test on a social...
-
Audrey purchases a riding lawnmower using a 2-year, no-interest deferred payment plan at Lawn Depot for x dollars. There was a down payment of d dollars and a monthly payment of m dollars. Express...
-
A robot will be operated by NASA to build a permanent lunar station. The position control system for the gripper tool is shown in Figure 10.1(a), where //(5) = I, and Determine a compensator lag...
-
A system has a block diagram as shown in Figure AP2.2. Determine the transfer function T(s) = Y2(s) / R1(s) It is desired to decouple Y2(s) from R1(s) by obtaining T(s) = 0. Select G5(s) in terms of...
-
A manipulator control system has a loop transfer function of and negative unity feedback [15]. Represent this system by a state variable signal-flow graph or block diagram and a vector differential...
-
The joint density function of two random variables \(X\) and \(Y\) is given by \[p_{X, Y}(x, y)= \begin{cases}\frac{x y}{9}, & 0 \leq x \leq 2,0 \leq y \leq 3 \\ 0, & \text { elsewhere }\end{cases}\]...
-
Define the correlation coefficient, \(ho_{X Y}\).
-
True or False. The autocorrelation function \(R\left(t_{1}, t_{2} ight)\) is the same as \(E\left[x\left(t_{1} ight) x\left(t_{2} ight) ight]\).
Study smarter with the SolutionInn App