Which of the following is NOT a valid method to increase a variable named score by 1?

a.
++score = score + 1

b.
score = score + 1

c.
score++

d.
++score

Answers

Answer 1

Answer:

a.

++score = score + 1

Explanation:

First you have to understand the increment operator;

There are three possible ways to increment the value of variable by 1.

1.  post increment

syntax:

name++

it using in expression first then increase the value by 1.

2. Pre increment

syntax:

++name

it increase the value by 1 before it using in expression.

3. simple method

name = name +1

In the question,

option 1: ++score = score + 1

it increase the value of score by 2 because their are two increment is used first for (score + 1) and second ++score.

Therefore, the correct option is a.


Related Questions

Which of the following is the new linecharacter?\r\n\l\b

Answers

Answer:

\n

Explanation:

\n is called the new line character.It is used to go to the next line or the start of the new line.\n is used in Linux while in windows uses \r\n called carriage return.But generally \n is used in most of the programming languages also.

__________ refers to the idea that eachemployee should report

to only one manager.

a. Span of control

b. Unity of command principle

c. Emergent leadership

d. Bureaucracy

Answers

Answer:

The correct answer is B. Unity of command principle refers to the idea that each employee should report to only one manager.

Explanation:

The Unity of Command Principle is one of the 14 administration principles imposed by Henry Fayol that determines that none of the employees of an organization should receive orders from more than one superior.

That is to say, the principle of the unity of command establishes that no employee should have more than one superior in order to avoid confusing situations and disorders that affect the productivity of the organization in question.

Which of the following is a true statement?

a. Message body in reachable by the main program.

b. Two methods can have the same header.

c. Formal and actual parameters may have the samenames.

d. Local variables are recognized by the mainprogram.

Answers

Answer: D. Local variables are recognized by the main program

Explanation: Local variables can be accessed in the function that they are defined within .If you require the variables which should be accessible by  every function in a particular program the they should be defined globally in the program . Therefore  local variables are recognized by the main program throughout.

Answer:

d. Local variables are recognized by the main program.

Explanation:

Local variables are recognized by the main program, is a true statement.

However, message body in reachable by the main program, two methods can have the same header, and formal and actual parameters may have the same names are NOT true statements.

)What is proceduralabstraction, and why is it important inComputer Science

Answers

Answer:

Procedural abstraction is a method in which all sub tasks of a whole functionality must be created separately as method and each method/ procedure must be performing a distinct functionality. For example if we want to write a program to calculate and display result of students in class and create separate methods to get students record, to calculate grades to display results is a procedural abstraction approach. Here not only the methods created have distinctive function the administrative can vary the level of abstraction as well.

It is important in computer science for the following ways:

1) Increase the level of code readiness as all separate functionality tasks will have a separate methods.

2) Prevents unauthorized of data.

A class diagram _____.
Answer

provides an overview of a class's data and methods

provides method implementation details

is never used by nonprogrammers because it is too technical

all of the above

Answers

Answer:

provides an overview of class's data and methods

Explanation:

Class Diagram is used in software engineering to represent:

- classes

- attributes

- methods

- relationship between classes

It provides a representation of the static layout of the application in object oriented design. It does not provide method implementation details. In fact code skeleton can be automatically generated from class diagram using appropriate UML tools.

C++ programming true or false questions

1. We have a class called animalType. Answer the following questions about clas animalType.

a. Its constructors will be named animalType. (True or False)

b. Return type of its constructors will be void. (True or False)

Answers

Answer:

a. True

b. False

Explanation:

Constructor is used to initialize the object of the class.

Rules of constructor:

1. Constructor name must same as the class name. it means, if the class name is animalType, then constructor name must be animalType.

2. Constructor does not have any return type. it means, it does not return anythings.

Therefore, part (a) is true,  Constructor name must same as the class name.

and part (b) is false, because constructor does not have any return type.

What is the

stored program concept?

Answers

Answer:

 The stored program concept is defined as, in the architecture of computer where computer acts as internal store instruction and it is important because has high flexibility and user does not required to execute the instruction again and again. It is basically works on the principle of Von neumann architecture, as in which the instruction and the data are both same logically and can be used to store in the memory.

The simplest statement you can use to make a decision is the ____ statement.

a.
Boolean

b.
true false

c.
if

d.
this

Answers

A is the answer to the question

The simplest statement you can use to make a decision is the if statement. Thus, option C is correct.

What is a statement?

A statement within a programming language is just a syntactic construct of an arbitrary programming language that also expresses a course of action. A series of one or more statements make up a program built in this language. There could be internal parts to a proposition.

The simplest illustration of a decision framework in Java seems to be the if statement. A conceptual test that can result in a positive or negative outcome is expressed in an if statement.

The if statements inside the if the branch were carried out if the test's outcome is true. In this case, the statement can either be true or the statement can either be false depending upon the condition.

Therefore, option C is the correct option.

Learn more about statement, here:

https://brainly.com/question/20837448

#SPJ6

What are different types of inner classes ?

Answers

Answer:

Inner class in Java is basically a class in a class, i.e. a member of another class.

There are 4 types of inner classes in Java.

a)  Nested Inner class

b)  Method local Inner class

c)  Anonymous Inner class

d)  Static nested class

The _________ is the part of a function definition that shows the function name, return

type, and parameter list.

Answers

Answer:

The function prototype is the part of a function definition that shows the function name, return type, and parameter list.

Explanation:-

In general we write a function definition as:

return_type function_name(parameter list)   //this is the prototype

{

    //function body

}

Final answer:

The term that completes the student's sentence is 'function header' or 'prototype', which includes the function name, return type, and parameters. It is essential for understanding how to use the function and what to expect from it.

Explanation:

The blank in the student's question should be filled with the term function header or prototype. This is the part of a function definition that shows the function name, return type, and parameter list. The function header specifies what the function is called, what type of data it returns, and what arguments it takes. The structure of the function header can vary between programming languages, but generally it includes the function name, followed by parentheses that contain the parameters (or arguments), and prefixed by the return type.

For example, in the function definition of int main(), 'int' is the return type indicating that the function will return an integer value, 'main' is the function name, and the empty parentheses indicate that this function takes no arguments. In another example, a function named 'f' might take three arguments - a, b, and c - and work with them internally to produce a result.

Understanding the function header is crucial for programming because it allows you to know how to properly call the function and what kind of data to expect back from it. Creating clear and concise function headers makes programs easier to read, understand, and debug.

Reference variables allow arguments to be passed by ____________.

Answers

Answer:

Reference

Explanation:

The Reference type variable is such type of variable in C# that holds the reference of memory address instead of value. Examples for reference type are classes, interfaces, delegates and arrays.

We can pass parameters to the method by reference using ref keyword

It’s mandatory to initialize the variable value before we pass it as an argument to the method in c#

For example,

int x = 10;  // Variable need to be initialized

Add(ref x); // method call

If you pass parameters by reference in method definition, any changes made to it affect the other variable in method call.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           int i = 10;

           Console.WriteLine("i=" + i);

           Add(ref i);

           Console.WriteLine("i=" + i);

           Console.ReadLine();

       }

       public static void Add( ref int j)

       {

           j = j + 10;

           Console.WriteLine("j="+j);

       }

   }

}

Output:

i=10

j=20

i=20

Why we need each section of prologprogram?

Answers

Answer:

Prolog program are used in the artificial intelligence and the web development in a systematic manner process. As, it is also sometimes known as declarative language which basically consist of some facts and list. Prolog program are divided into the sections that are:

Domain sectionsClauses sectionsPredicates sectionsGoal sections

We need each section of the prolog program because all the sections introduced the systematic program and performed there particular functions so by using all these processing steps an efficient function are formed.

Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bag_ounces followed by "seconds". End with a newline.

Answers

Answer:

void print_popcorn_time(int bag_ounces){

   if(bag_ounces < 3){

       cout<<"Too small"<<endl;

   }else if(bag_ounces > 10){

       cout<<"Too large"<<endl;

   }else{

       cout<<(6 * bag_ounces)<<"seconds"<<endl;

   }

}

Explanation:

The function is the block of the statement which performs the special task.

For checking the condition in the program, the if-else statement is used.

It can check the condition one or two but if we want to check the more than two different conditions then the continuous if-else statement is used.

syntax of continuous if else:

if(condition){

statement;

}else if(condition)

statement;

}else{

statement;

}

In the question, there are three conditions;

1. bag_ounces is less than 3

2. bag_ounces greater than 10

3. else part.

we put the condition in the above if-else statement and print the corresponding message.

Answer:

def print_popcorn_time(bag_ounces):

   if bag_ounces < 3:

       print("Too small")

   elif bag_ounces > 10:

        print("Too large")

   else:

        bag_ounces = bag_ounces * 6

        print(bag_ounces, "seconds")

Explanation:

def print_popcorn_time(bag_ounces): #fed function

   if bag_ounces < 3:  #1st if statement

       print("Too small") #print function

   elif bag_ounces > 10: #else if

        print("Too large") #print than print

   else:  #else:

        bag_ounces = bag_ounces * 6 #do work

        print(bag_ounces, "seconds") #print

Suppose a vector of ints initially has these 8 elements:
6 7 5 9 1 3 2 4
(a) How many swaps will be performed during a selection sort of the elements?

Answers

Answer:

Using the Selection Sort algorithm there will be 5 swaps in total within the vector of ints.

Explanation:

A Selection Sort algorithm compares the first value in the vector with the rest of the values and swaps it for the lowest value. It then moves on to the next value in the vector and repeats the process until the whole vector is sorted.

Initial Vector : 6 7 5 9 1 3 2 4

1st Swap :   1 7 5 9 6 3 2 4

2nd Swap:  1 2 5 9 6 3 7 4

3rd Swap :  1 2 3 9 6 5 7 4

4rth Swap:  1 2 3 4 6 5 7 9

5th Swap:   1 2 3 4 5 6 7 9

After the 5th Swap the Vector is completely Sorted.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

Values that are sent into a function are called _________.

Program Output

Answers

Answer:

Argument

Explanation:

The function is the block of the statement which performs the special task.

when we define the function in the program then we have to call that function.

the syntax for defining the function:

type name(parameter_1, parameter_2,...){

    statement;

}

the syntax for calling the function:

name( argument_1, argument_2,...);

Meaning of parameter and argument

The argument is used to send the value into the function definition. this can be passed by value or pass by reference.

The parameter is used to receive the value send by calling function.

Therefore, the answer is the Argument.

Which statement will call this module and pass 12 as the argument?

Module showValue (Integer quantity)

Answer
a) Call showValue( Integer)

b) Call showValue (12)



c) Call showValue( Integer 12)

d) Call showValue( Real)

Answers

Answer:

Call showValue (12)

Explanation:

The function is a block of the statement which performs the special task.

if you define the function, then you have to call that function.

Then, program control moves to the function and start to execute otherwise not execute the function.

the syntax for calling the function:

name(argument_1, argument_2,....);

we can put any number of arguments in the calling.

check the options one by one for finding the answer:

Call showValue( Integer): this is valid calling but it passes the variable, not the 12. this is not correct.

Call showValue( Integer 12): This is not valid calling, because it passes the data type as well which is incorrect.

Call showValue( Real): this is valid calling but it passes the variable, not the 12. this is not correct.

Call showValue (12): this valid calling and also pass the value 12.

Therefore, the correct answer is option b.

When a method returns an array reference, you include ____ with the return type in the method header.

a.
( )

b.
[ ]

c.
< >

d.
{ }

Answers

Answer:

b. []

Explanation:

Arrays are represented using [] . When a method returns an array reference, the method header contains an entry of the type <data-type>[].

For example, a method test which returns a reference to integer array and takes no parameters is of the form:

int[] test();

Similarly a method list_chars which takes a String as an argument and returns an array of chars has the form:

char[] list_chars(String s);

In java, Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 20:

Answers

Answer:

while(userNum > 1){

        userNum = userNum /2;

        System.out.print(userNum+" ");

     }

Explanation:

Probably don't need the print statement, but it doesn't cause an error.

This solution uses a while loop in Java to repeatedly divide a number by 2 and print the result until the number is less than 1. The example code and explanation illustrate the process clearly.

To solve this problem, you need to write a while loop in Java. This loop will continue dividing the given number by 2 until it reaches 1. Here's the step-by-step solution:

Example Code:

import java.util.Scanner;
public class Main {
   public static void main(String[] args) {
       Scanner scanner = new Scanner(System.in);
       int userNum = 20; // You can change this to any number.
       while (userNum >= 1) {
           System.out.print(userNum + " ");
           userNum = userNum / 2;
       }
   }
}

In this code:

We initialize userNum with a value (20 in this example).The while loop continues as long as userNum is greater than or equal to 1.In each iteration, we print userNum followed by a space and then divide it by 2 using integer division.

The output for userNum = 20 will be: 20 10 5 2 1 .

When an integer is subtracted from a pointer variable, the value of the pointer variable is decremented by the integer times half the size of the memory to which the pointer is pointing.

True

False

Answers

Answer:

False

Explanation:

When you apply subtraction (arithmetic operation) on Pointer variable ,then pointer variable is decremented by the (integer*sizeofmemory).

Example

            #include<stdio.h>

           //driver function

             int main()

          {

            float *ptr=(float *)100; //initializing  ptr as pointer type

            ptr=ptr-2; //subtracting pointer by 2(integer)

           printf("New Value of ptr is %u",ptr);

            return 0;

          }

Output

New Value of ptr is 92

Explanation of Code

ptr = ptr   - 2 * (sizeof(float))

   = 100  - 2 * (4) //float size is 4 bytes

   = 100  - 8

   = 92

Do you think there are some disadvantages to "For Loop"? Or when using it is not good for its program?

Answers

Answer:

I think there are no disadvantages of for loop as far as i know.

Since for loop is entry controlled loop (i.e , the condition is checked for entering in the loop body).So when you want to execute the body first in the program for loops are not good fit for this type of conditions.You can use do while loop in these cases which is an exit controlled loop(body is executed first after the condition is checked) .

for example:-Iterating over and printing the circular linked list.

with open source operating systems,both the executable code and source code are available:

true or false?

Answers

Answer:v True

Explanation: Open source operating system is the system that has source code that can be modified and enhance them . It can also be shared between the public as it is available in the open form . There are many examples of the open source operating system like Linux, Ubuntu etc. which has both executable code and source code as well. so therefore the given statement is true.

. What is an RFC?How it's produced?

Answers

Answer: Request for Comments(RFC)is an official document containing methods, behaviors, research, internet specifications, protocols in systems connected to the internet.

RFC are produced by computer scientist , experts in the field of networking, protocols who author them and then send for approval from Internet Engineering Task Force(IETF). After there approval it is then assigned a serial number after which it cannot be modified.

Explanation:

RFC is an official document to propose and bring out new changes in the field of engineering and communication.

Once RFC has been produces it can also bring out modifications in the form of amendments.

Suppose you want to write a program that will read a list of numbers from a user, place them into an array and then compute their average. How large should you make the array?

Answers

Answer:

The size of the array is dependent on the amount of memory the program can access.

Explanation:

Here according to the question the user is in need of memory space equal to the amount of numbers read from the list. So the size of the array should be equal to the total numbers read from the list. if the user reads 5 number from the list then the size of the array should be int a[5] if the numbers are integers. Wastage of memory space is not appreciated in a good piece of code.

- What is the final value of the variable myPar given the following code fragment? int counter = 5; int myPar = 1; do { myPar = myPar + 2; counter = counter + 1; } while(counter <= 1);

Answers

Answer:

3

Explanation:

do-while is the loop statement used for executing the part of the code again and again until the condition not false.

when the condition is false, the program terminates the loop statement and starts executing the next of the do-while statement.

It has the special property, it executes the statement first and then checks the condition.

So, it executes the statement once if we provide the condition false.

Another side, the other loop statement like for loop, while loop they check the condition first and then start executing the statement if condition true.

In the question, the counter is 5 and myPar is 1

then the program executes the statement first.

so, myPar = 1+2=3

myPar assigns through the value 3. then counter increase by one.

the counter value becomes 2.

then check the condition 2 <= 1, condition false and program terminate.

Therefore, the answer is 3.

The minimum spanning tree of an undirected graph G exists if and only if G is connected. True or False?

Answers

Answer: True

Explanation:

The definition of minimum spanning tree(MST) says that the graph must be connected and undirected to be considered for MST. It has (V-1) edges where V is the number of vertices. The minimum spanning tree is implemented using Kruskal's algorithm whereby it starts by considering the minimum weighted edge and covers all the edges upto (V-1) edges. So for MST it has to be connected

Describe the input/output characteristic of a workstation/PC thatcan be used by engineers for computer-aided design.

Answers

Answer and Explanation:

The characteristics of input/output of PC/workstation can be described as:

Input/Ouput devices works as the interface between the user and the device. It provides us to give commands to our system and get the outputs as per the commands or instructions provided.

Input devices are those which allow us to give instructions or commands to our system like that of a keyboard in a PC, it allows us to write into our system and give commands to it to perform a particular task. these instructions are then converted into signals to be readable by the system(machine language). Another input device is mouse.

Output devices are those which provides us with the desired results converted in the form readable by us. Like monitor of our PC displays the desired results and same goes for printer it prints the results.

There are different input/output files for different operating systems as in 'C' there is a whole library for input/out commands.

ETL & ELT are thesame.? True? False

Answers

Answer:

False.

Explanation:

ETL & ELT are NOT the same.

wHAT ARE THE 5 LAYERS in the internet protocol stack andwhat are the principal responsibilities of eack of theselayers.?

Answers

Answer: The 5 different layers in the IP stack are as follows:

1. Physical Layer

2. Data Link Layer

3. Network Layer

4. Transport Layer

5. Application Layer

Explanation:

The functions of the different layers are:

The physical layer is concerned with transfer of bits  across the different nodes, The data link layer is concerned with transmission of frames with error detection and correction. The network layer is concerned with routing the packets across various nodes in the router. The transport layer deal with the implementation of protocols such as TCP and UDP. The Application layer host a numerous software applications such as  HTTP, SMTP for client server connections.

What to do: please remember to comment each line.
1 Initialize x to be zero

2 Prompt the user for the next operation (Addition or Subtraction)

3 Prompt the user for the next operand (y).

4 Perform the operation (x + y or x – y depends on the operation selected by
the user), and store back the result to x.

5 Output x in decimal.

6 Go back to step 2 until user input “q” as the next operation, then exit.

Answers

Answer:

#include <iostream>

using namespace std;

int main()

{

   //initialization

  float x=0.0;

  float y;

  char operation;

  //print the message

   cout<<"Please enter the operation (Addition or Subtraction): ";

   cin>>operation;

   //loop for enter th operand again until enter 'q'

  while(operation != 'q'){

       //print the message for operand x

      cout<<"\nPlease enter the operand x: ";

      cin>>x;

       //print the message for operand y

      cout<<"\nPlease enter the operand y: ";

      cin>>y;

   //check for condition for '+' and if true then add the operands

      if(operation == '+'){

          x=x+y;

      }else if(operation == '-'){  //if user enter '-' then subtract the operands

          x=x-y;

      }

      //print the output

      cout<<"\nThe output is: "<<x<<endl;

      cout<<"\nPlease enter the operation (Addition or Subtraction): ";

      cin>>operation;

  }

  return 0;

}

Explanation:

Create the main function and define the variable x equals zero and declare the variables y and operation.

print the message for the user to enter the operation ('+' or '-') by using the instruction cout.

Store the value in the variable by using the instruction cin.

Then, take the loop to repeat the statement again and again until the condition is true.

print the message inside the loop for asking about the operands from the user.

then, use condition statement for checking the operation and if condition match, then execute the particular operation.

The above operation executes until the user enters not enter the character 'q'.

when the user enters the 'q', the loop terminates and print the output.

Methods used with object instantiations are called ____ methods.

a.
accessor

b.
instance

c.
internal

d.
static

Answers

Answer:

b. instance

Explanation:

Methods used with object instantiations are the instance methods. When a class is instantiated we get a reference to the object. Invoking a method on the object , executes the corresponding instance method.

For example:

String s = new String("test");

int len = s.length();

Here length() is an instance method of String object s.

Other Questions
In Java, which of these classes implement the LayoutManagerinterface??? RowLayout?? ColumnLayout?? GridBagLayout?? FlowLayoutManager Los beisbolistas _______ de una base a otra.Question 1 options:a)bateanb)corren When in 1915 Italy threw in her fate with that of the Allies, how many cries of admiration, how many promises were heard? But after the common victory, which cost Italy six hundred thousand dead, four hundred thousand lost, one million wounded, when peace was being discussed around the table only the crumbs of a rich colonial LOOT were left for us to pick up. For thirteen years we have been patient while the circle tightened around us at the hands of those who wish to suffocate us. What argument is Mussolini making in this passage? A.Italy did not get the territory it deserved after World War I. B.The Allies refused to make fair promises to Italy during the war. C.Italy won colonial territory but lost it in World War I. D.Italy lost more soldiers than the other Allied countries. How did wegners theory of continental drift differ from the current theory of plate tectonics Myelin Select one: a. is released from a neuron and travels to another neuron. b. consists of layers of lipids and proteins that wrap around an axon. c. is produced in response to bacterial infection. d. is a form of chromatophilic substance that fills Schwann cells. Using the Lewis Dot Structure, what does IF6+ look like?I need this as soon as possible tytyy A pipe which is on a slope, transports water downwards. A doubling of cross sectional area takes place 6 above the reference level. The pressure in the smaller pipe, just before the enlargement, is 860 kPa. The flow velocity in the large pipe is 2,4 m/s. Determine the pressure in kPa at a point 1,5 m above the reference level. Ignore friction losses. The outstanding stock is composed of 10,000 shares of $100 par, cumulative preferred 5% stock, and 50,000 shares of $20 par common stock. Preferred dividends have been paid every year except for the preceding two years and the current year. If $145,000 is to be distributed as a dividend for the current year, what total amount will be distributed to the preferred stockholders? solve the following equations:2x-5y-4 x+6y=15 Which of the following factors could you change in a system and not change its induced EMF?A. magnetic fieldB. type of wireC. velocity of the wireD. length of the wire in the field Simplify the given equation.5x + 2(x - 3) = -2(x - 1)078-6--2X-27x - 6 = -2x + 27x - 3 = -2x - 1 If a point is on the perpendicular bisector of a segment then it is If 25 kg of ice at 0C is combined with 4 kg of steam at 100C, what will be the final equilibrium temperature (in C) of the system? Latent heat of fusion of ice = 3.34 x 105 J.kg-1 Latent heat of steam = 2.23 x 106 J.kg-1 Specific heat of water = 4180 J.kg-1.K-1 Who founded the Kingdom of Ghana?A)GriotsB)The SoninkeC)The MandinkaD)Arab traders Hector is a state court judge. Ilena appears in a case in Hectors court, claiming that Jacob breached a contract. Possible remedies include a. imprisonment. b. an award of damages. c. a criminal fine. d. compensation to Hector for a favorable ruling. A body initially at rest explodes into two masses M1 and M2 that moves apart with speeds v1 and v2 respectively. what is the ratio v1/v2?a)-M2/M1b)M2/M1 an office worker earns R6400 per month. his monthly expenses are 1/5 for rent , 2/7 for car payment, 1/6 for insurance, 1/3 for other monthly living expenses and the rest he deposits into a savings account. how much does he save per month? Convert: Thermal conductivity value of 0.3 Btu/(h ftF) to W/(m C). Surface heat transfer coefficient value of 105 Btu/(h ft2 oF) to W/(m20C) The leaks began at about two or three. The first was in the corner of Nademahs bedroom. Zeitoun went down to the garage and retrieved a forty-gallon garbage can to catch the water. Another leak opened a few minutes later, this one in the upstairs hallway. Zeitoun found another garbage can. A window in the master bedroom broke just after three oclock, as if a brick had been thrown through the glass. Zeitoun gathered the shards and stuffed the opening with a pillow. Another leak opened in Safiya and Aishas room. He found another, bigger garbage can. What conclusion can readers draw about this character vs.nature conflict? Stemway Company requires a new manufacturing facility. It found three locations; all of which would provide the needed capacity, the only difference is the price. Location A may be purchased for $500,000. Location B may be acquired with a down payment of $100,000 and annual payments at the end of each of the next twenty years of $50,000. Location C requires $40,000 payments at the beginning of each of the next twenty-five years. Assuming Stemway borrowing costs are 8% per annum, which option is the least costly to the company?