Answer:
There is only one modification in the above loop i.e. while loop should be like this--
while (i != n)
{
sum+=arr[i]; // Line 1, In question segment it is line 2.
i++; // Line 2, In question segment it is line 1.
}
Output:
Now if the array input is 1,2,3,4,5 then the output is 15.
Explanation:
In the above question, all the line of the segment is right except the body of the loop because--
- The First line of the loop is increment statement which increments the value of "i" variable from 1 and the value of "i" variable will be 1 in the first iteration of the loop
- The second line starts to add the value from 1'st index position of the array. Hence the segment gives the wrong answer. It adds the arr[1] to arr[n-1].
- So I interchanged both lines of the while loop as shown in the answer part. I make the line 1 (In question segment) as line 2(In answer part) and line 2 (In question segment) as line 1 (In answer part).
Now It gives the correct output because it can add arr[0] to arr[n-1].
Right click the text you want to format, On the home tab click the line and paragraph spacing command . A drop down menu will appear. Move the mouse over the various options . The line spacing will change in the document.
Was that helpful?
Answer:
Partial and disjoint
Explanation:
Since there is overlapping in relationship of HAIR_STYLIST and MANAGER it can't be tree structure.
A MANAGER can or can't be HAIR_STYLIST. In order for the relationship to be multiple inhertiance am entity in sub-class has to be union of all subclasses
In single inheritance, a sub-class has to be a union of a single super class.
In partial and disjoint, some entity in super class may or may not be related to a sub-class.
Answer:
Option (B) and (C) is the correct option to the following question.
Explanation:
Because the function is the module of the program and we call that function again and again anywhere whenever we need that function in the program.
Function is used to carry out any operation which is used in the program many times and it creates the program short and simple.
<u>For example</u>: if we need to add or multiply two numbers many times in the program then, we create one or two functions for addition and subtraction or one program for both, when we need them we call them.
Answer:
this will be okay but if this does not match with her needs then she can create her own picture to match