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
Readme [11.4K]
3 years ago
5

1. What will the println statement in the following program segment display? int x = 5; System.out.println(x++); a. 5 b. 6 c. 0

d. None of these
Computers and Technology
1 answer:
garik1379 [7]3 years ago
8 0

Answer: a) 5

Explanation:

x++ increases the value of x by 1 (=6), but still returns the old value (5) to the print statement

following code lines will use the new x=6 value

You might be interested in
Why ads on this app do it help pay for the free stuff?
UNO [17]

Answer:

Yes

Explanation:

The ads help support the system for you using this website for free.

4 0
2 years ago
For a set of integers stored in an array,calculate the sum of the positive numbers and the sum of the negative numbers. The prog
Radda [10]

Answer: The c++ program to implement the given conditions is shown below.

#include <iostream>

using namespace std;

int main()

{

// used as index of array in the loop for calculating the sum

   int i=0;

// array contains both negative and positive integers

// 0 is used as the sentinel value

   int arr[12]={-9,-8,-3,-12,-78,-10,23,45,67,1,0};

   int positiveSum=0, negativeSum=0;

   do

   {

       if(arr[i]<0)

           negativeSum = negativeSum + arr[i];

       if(arr[i]>0)

           positiveSum = positiveSum  + arr[i];

// after every element is added, index of array represented by i is incremented

       i++;

   }while(arr[i]!=0);

// loop continues till end of array is reached

   cout<<"Sum of positive integers "<<positiveSum<<" and sum of negative integers "<<negativeSum<<endl;

   return 0;

}

OUTPUT

Sum of positive integers 136 and sum of negative integers -120

Explanation: This program declares and initializes an integer array without user input. As mentioned in the question, 0 is taken as the sentinel value which shows the end of data in the array.

   int arr[12]={-9,-8,-3,-12,-78,-10,23,45,67,1,0};

All the variables are declared with data type int, not float. Since, integers can yield integer result only.

The do-while loop is used to calculate the sum of both positive and negative integers using int variable i. The variable i is initialized to 0.

This loop will run till it encounters the sentinel value 0 as shown.

while(arr[i]!=0);

Hence, all the integers in the array are read one at a time and sum is calculated irrespective of the element is positive or negative.

       if(arr[i]<0)

           negativeSum = negativeSum + arr[i];

       if(arr[i]>0)

           positiveSum = positiveSum  + arr[i];

After the element is added, variable i is incremented and loop is continued.

The do-while loop tests positive and negative integers based on the fact whether their value is greater than or less than 0.

The program can be tested using different size and different values of positive and negative integers in the array.

7 0
4 years ago
Python uses standard order of operations to evaluate equations. True False
Strike441 [17]

Answer:

False... Can you give me brainliest

Explanation:

6 0
3 years ago
Which of the following is a proper use of the application NetStumbler?Which of the following is a proper use of the application
Eddi Din [679]

Answer:

Finding rogue access points within your network

Explanation:

A

5 0
4 years ago
Read 2 more answers
What are midi signals
gregori [183]

Answer: is a unified standard used when recording the sounds of instruments

3 0
3 years ago
Read 2 more answers
Other questions:
  • Write an overloaded constructor for the Table class that will take a single argument for the color of the table Write a set meth
    13·1 answer
  • Where do you go to create a workbook?​
    8·1 answer
  • Can you give me a long list of kid's cartoons
    8·2 answers
  • 5. RAM IS YOUR SYSTEM’S-
    14·2 answers
  • Create a dictionary that will hold AT LEAST 3 categories for food with at least 3 foods for each category. E.g. Fruits --&gt; Ap
    6·1 answer
  • An operating environment for a computer is ____, free of potential contaminants, and with the temperature and humidity range spe
    9·1 answer
  • What are the words that make up a high-level programming language called?
    6·1 answer
  • Everyone say bye to brainly cause I’m reporting it for being against the law
    10·2 answers
  • What are the two main types of citing information?
    12·2 answers
  • AUPs ensure that an organization’s network and internet are not abused. Select 3 options that describe AUPs.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!