1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
cluponka [151]
3 years ago
10

What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 11) { sum = sum + i; i++; } System.out

.println("The value of sum is " + sum); The value of sum is 65. The value of sum is 66. The value of sum is 55. The value of sum is 56.
Computers and Technology
1 answer:
valentina_108 [34]3 years ago
7 0

Answer:

The value of sum is 66

Explanation:

i = 1

sum = 0

while (i <= 11) {  

sum = sum + i;

i++;  

}

i = 1

  • sum = sum + i
  • sum = 0 + 1
  • sum = 1

i = 2

  • sum = sum + i
  • sum = 1 + 2
  • sum = 3

i = 3

  • sum = sum + i
  • sum = 3 + 3
  • sum = 6

i = 4

  • sum = sum + i
  • sum = 6 + 4
  • sum = 10

i = 5

  • sum = sum + i
  • sum = 10 + 5
  • sum = 15

i = 6

  • sum = sum + i
  • sum = 15 + 6
  • sum = 21

i = 7

  • sum = sum + i
  • sum = 21 + 7
  • sum = 28

i = 8

  • sum = sum + i
  • sum = 28 + 8
  • sum = 36

i = 9

  • sum = sum + i
  • sum = 36 + 9
  • sum = 45

i = 10

  • sum = sum + i
  • sum = 45 + 10
  • sum = 55

i = 11

  • sum = sum + i
  • sum = 55 + 11
  • sum = 66

i = 12 --> does not comply with the condition "i < = 11", the while loop is over

You might be interested in
What is the primary cause of the industrial revolution?
Whitepunk [10]

Explanation:

heyy

everyone come here for truth and dare

vzg-hqvy-wdn

5 0
3 years ago
Which of the Arts, A/V Technology, and Communication career cluster pathways are involved with producing a product for an audien
PIT_PIT [208]

I believe the pathways are Audio/Visual Technology and Film, Journalism and Broadcasting and Printing Technology .


5 0
3 years ago
Read 2 more answers
Creative Commons Question -- At home, you created a really great digital song, audio jingle, or music track using some software
galina1969 [7]
C. It's honestly up to the user, upload so others can use it or make it so its copyrighted and make some cash :P
6 0
2 years ago
1D Array Assignment Outcome: Student will demonstrate the ability to use a one-dimensional array. Student will demonstrate the a
sukhopar [10]

Answer:

Program to this question as follows:

program:

import java.util.*; //import package for user input

public class Main  //defining class  

{

public static void main(String[] as)//defining main function

{//defining integer array

int [] num = new int[113];  

boolean find_in = false; //defining boolean variable

int [] counts = new int[101];//defining integer array

int y, tem = 0, counter = 0,in=0,x,find; //defining integer variable

Scanner ox= new Scanner(System.in); //creating Scanner class Object

while(counter <= 112) //loop to check condition

{

num[counter++] = generateRandomNumber(); //using array to hold random function value.  

}

System.out.println("The array:"); //message

for(x = 0; x < 112; x++) // loop to count the value

{

if(x != 0 && x % 9 == 0) // if block to chek value

System.out.println(); // print  

else

System.out.print(num[x] + " "); // print array

}

// sort in ascending order

Arrays.sort(num); //using sort method

System.out.print("\n\nThe array in sorted order:"); // print value

for( x = 0; x < num.length; x++) // loop uses if block to check value is divisiable by 9  

{

if(x % 9 == 0) //check condition  

System.out.println(); // print  

else

System.out.print(num[x] + " "); // print array

}

// search for a number

System.out.print("\n\nEnter a number to search: "); // print message

find= ox.nextInt(); // input number by user

for(x= 0;x< num.length;x++) //loop to count values

{

if(num[x] == find) //check value

{

find_in = true; //change value

in= x;

break; //using break keyword

}

}

if(find_in)  //find value

System.out.println(find + " is found at index " + in); // print location

else

System.out.println("Not found"); //message

// display count of each numbers

System.out.println("Count of each numbers:"); //message

for(y = 1; y< num.length; y++) // loop to store element in counts array  

{

tem = num[y]; //hold value

counts[tem]++; //increment value

}

for(x = 1; x< counts.length; x++) //loop to print value

{

System.out.println(x + ": " + counts[x]); // print value

}

// average of the numbers in the array

for(x = 0; x < num.length; x++) // loop to calculate sum and average

{

sum += num[x]; //calculate sum

}

avg = (sum / 100); // calculate avg

System.out.println("\nThe average of the numbers in the array: " + avg);

// highest number in the array

int high= num[0]; //find number

for(x= 0;x < num.length;x++)

{

if(num[x] > high)

high = num[x]; //hold value of highest Number

}

System.out.println("\nThe highest number is: " + high); //print value

int low = num[0]; // defining variable for lowest number

for(x= 0; x < num.length - 1; x++) // loop to calculate lowest number

{

if(num[x] < low) //condition for lowest number

low = num[x]; //hold lowest number

}

System.out.println("\nThe lowest number is: " + low); //print value

}

public static int generateRandomNumber() //defining function  

{

Random ra = new Random(); //creating Random function Object

return (ra.nextInt(100)+ 1); //input and return value

}

}

Output:

the output of the given code is display in image

Explanation:

In the above program, an array is declared that uses a random function to input the number, in the next step the sort function is used, that sorted all array elements, in the next step the scanner class is used, that input the number form the user ends and pass search in the sorted array.

  • After searching the average of array elements is calculated. In this array we calculate the highest and lowest number of the array to print all the values the print method is used.
  • At the last, the rand method is used that generates the random number for the array and passes into a num array that prints the values.

7 0
3 years ago
Algorithm and flowchart to find the perimeter and area of square​
kupik [55]

Answer:

I can give you the perimeter "algorithm" but not the flowchart.

Here you go:

p = w * 4

p = perimiter,

w = width/height

4 = the amount of sides needed.

perimeter = width * 4

to include both width and height, we would instead use:

perimeter = 2(width+height)

This also works with rectangles ^

--------------------------------------------------------------------------

To find an area, it is just width * height. This is also compatible with rectangles.

4 0
3 years ago
Other questions:
  • What does subscribing to a website’s RSS feed provide to a subscriber?
    10·1 answer
  • What part of the communication feedback loop results in unclear communication?
    13·1 answer
  • Nikolas has a idea that he could use the compressed carbon dioxide in a fire extinguisher to propel him on his skateboard. Nikol
    13·2 answers
  • What is the best data structure to solve the following problem? a) A list needs to be built dynamically. b) Data must be easy to
    11·1 answer
  • What can a scientist do if he repeats and experiment and gets diffrent results?
    5·1 answer
  • E-mail messages, instant messages (IMs), or text messages sent and/or received within an organization a. are not included on a r
    9·1 answer
  • I need help picture above
    14·2 answers
  • An end-user license agreement protects _____.
    7·1 answer
  • 1. Es un símbolo que indica que se ha de realizar cierta operación específica entre uno o varios
    6·1 answer
  • A _____ is a computer that is deliberately set up to be easily hacked into.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!