What will the following code print out: int numbers [] = {99, 87, . 66, 55, 101}; for (int i = 1; i < 4; i++) cout << numbers [i] << end1;a) 99 87 66 55 101 b) 87 66 55 101 c) 87 66 55 d) Nothing.

Answers

Answer 1

Answer:

87 66 55

Explanation:

Array is used o store the multiple values with same data type.

the array show a decimal value .66, i assume this is enter by mistake because option has no decimal value.

The index of the array is start from zero, it means the first element store in the array at position zero.

In the for loop the variable 'i' start from 1 not zero and it goes to i<4 means i=3.

So, it access the element from 2 to 4 because the index is position of element less than 1.

Therefore, 87 66 55 print.


Related Questions

. ............... package is used by compiler itself. So it does not need to be imported for use.
A) java.math
B) java.awt
C) java.applet
D) java.lang

Answers

Answer: The compiler automatically imports the java.lang package.

Explanation:

Java packages are defined as a collection of classes, interfaces, and the like. Java programs utilize the components in the packages to implement their functionalities. Packages are either imported by the compiler or by the user through import keyword. The user can import any package using the import keyword. The import statements are always written at the beginning of the program.

import java.math.* ;

For example, the programmer writes the above statement that imports the java.math package into the java program.

Default packages are automatically imported by the compiler.

Default packages include java.lang packages. This default package is made up of all the classes and functions that are mandatory to any java program. Without java.lang package, the java program cannot be compiled and hence, becomes useless. The Java compiler adds the import statement for the default package, java.lang, at the beginning of the compilation. Hence, the statement

import java.lang.*;

does not needs to be written in the program.

The java.lang package consists of useful components which are required for various operations that can be done on the datatypes found in Java language. This package consists of classes and functions which relates to each data type and defines the functions which can be utilized to perform the operations allowed for the respective data types.

The java.lang package consists of Object, String, Math, System, Thread, Exception classes and wrapper classes like Integer, Double etc.. All the operations that can be implemented on the above-mentioned data types utilize the functions defined in their respective classes.

For example, printing on the console is done using System class.

System.out.println();

Also, all the operations done on strings use the methods such as append(), insert(), delete(), and replace(), etc, are pre-defined in the String class in the java.lang package.

Without java.lang package, any Java program cannot be useful.

A local variable that is declared as ____ causes the program to keep the variable and its latest value even when the function that declared it is through executing.
A) auto
B) static
C) extern
D) register

Answers

Answer:

A local variable that is declared as Static causes the program to keep the variable and its latest value even when the function that declared it is through executing.

Java provides a(n) ____ class, which contains many useful methods for manipulating arrays.

a.
Table

b.
Sort

c.
Arrays

d.
Object

Answers

Java presents Array Class, which contains many useful methods for manipulating "arrays".

It is essential because it introduces arrays and with that concept of "container variables".

Arrays are used everywhere.

Hope this helps.

r3t40

Digits Sum Write a function main( that reads a positive integer, calls the function digits which finds the digits sum of that integer. The function main( prints the sum. Sample input/output: Enter a positive integer: 20010 The digits sum of 20019 is 3

Answers

Answer:

#include<iostream>

using namespace std;

int digits(int number){

   int sum=0;

   while(number != 0){

       int rem = number % 10;

       sum = sum + rem;

       number = number/10;

   }

   return sum;

}

int main(){

   int number;

   cout<<"Enter the integer: ";

   cin>>number;

   int result = digits(number);

   cout<<"The sum of digits is: "<<result<<endl;

}

Explanation:

Include the library iostream for use of input/output.

Then, create the function digits with return type int.

Take a while loop and put a condition number not equal to zero.

the while loop executes the until the condition is not false.

In the while loop, take the remainder of the number and store in the rem variable.

after that, the store in the sum then reduces the number by dividing 10.

for example:

the number is 123.

rem = 123%10 it gives the value 3.

sum = 0+3=3

number = 123/10 it equal to 12

then,

rem = 12%10 it gives the value 2.

sum = 3+2=5

number = 12/10 is equal to 1

the same process executes until the number becomes zero and then the while loop terminates and the sum value returns to the main function.

create the main function and take the value from the user and call the function with the argument number.

and finally, print the result.

Kindly guide me How can I get the easy examples and tutorialsregarding:
a) Finite Automata
b) Transition Graph
c) Generalized Transition Graph
d) Kleen's Theorem

Answers

I thing it’s c but I’m not positive

_________ arguments are passed to parameters automatically if no argument is provided

in the function call.

Answers

Answer:

Default

Explanation:

When a Function is called, you pass a value to the parameter in function Call, and control is transferred to function definition. Parameters are optional that is, a function may contain no parameters.

Function definition contains the block of code to perform a specific task. Default arguments are passed to parameters in function definition if no argument is passed in function call.

Example: C program

#include <stdio.h>    

int s();  //Function declaration

 int main()  

{  

   int n;  

   n = s();  //Function calling with no parameters

   printf("\nSum  = %d", n);  

   return 0;  

}    

int s()  //Function definition

{  

   int c = 50, d = 80, s;  

   s = (c) + (d);  

   return s;  

}

Output:

Sum=130

The true or false questions.

1.egrep can accept multiple filenames as input arguments.

Answers

Answer: True  

Explanation: yes, it is true that egrep can accept multiple filenames as input arguments for example egrep -r "text1/text2", so this will search in all the sub directories . E grep is also known as 'grep -E' which belongs to the group of grep function and we used egrep to separate multiple patterns for OR conditions. This is also very less time consuming if you are going to search multiple input arguments in multiple different logs at the same time.

How would you copy all files from a remote directory into your LOCAL home folder.

Answers

Answer: Using secure copy 'SCP' we can copy all files from a remote directory into local folder. It also replaces existing files.

Explanation:

This is illustrated as follows:

scp -r username@IP:/path/to/server/source/folder/  .

-r is recursively copy all files

username is your username in your system

IP, here you cab specify the IP or type the website such as www.google.com

Then we specify the path, complete path

"." dot here refers the current directory. To copy the contents in the current directory.

Write a C++ code that will read a line of text convert it to all lower case and print it in the reverse order. Assume the maximum length of the text is 80 characters. Example input/output is shown below:

Input:

Hello sir

Output:

ris olleh

Answers

C++ program for converting it into lower case and printing in reverse order

#include <iostream>

#include <string>

#include <cctype>

using namespace std;

//driver function

int main()

{

// Declaring two string Variables

//strin to store Input string

//low_string to store the string in Lower Case

string strin, low_string;

int i=0;

cout<<"Input string: "<<endl;

/*getline()method is used to store the characters from Input stream to strin string */

getline(cin,strin);

//size()method returns the length of the string.

int length=strin.size();

//tolower() method changes the case of a single character at a time.

// loop is used to convert the entire Input string to lowercase.

while (strin[i])

{

  char c=strin[i];

  low_string[i]=tolower(c);

   i++;

}

//Checking the length of characters is less than 80

if(length<80)

 {

    cout<<"Output string: "<<endl;

   //Printing the Input string in reverse order, character by character.

    for(int i=length-1;i>=0;i--)

   {

    cout<<low_string[i];

   }

cout<<endl;

}

else

    {

       cout<<"string Length Exceeds 80(Max character Limit)"<<endl;

    }

return 0;

}

Output-

Input string:

Hello sir

Output string:

ris olleh

The Flow of Control refers to the order in which statements are executed. TRUE FALSE

Answers

Answer:

TRUE

Explanation:

The Flow of Control refers to the order in which the statements are executed.

One can understand the code if he knows the flow of control.

electronic business includes which of the following

A. servicing customers

B. buying and selling

C. conducting electronic transactions within an organization

D all of these

Answers

Answer:

D. all of these

Explanation:

Electronic business includes :  servicing customers, buying and selling , conducting electronic transactions within an organization.

Answer is all of these- D.

The size of selcetor registor in protectedmode is
a.32 bits, b. 24 bits,c. 16 bit, d.none of these option

Answers

Answer: c) 16 bits

Explanation: Protected mode is the mode which works when the phase of CPU of an operating system which allows to use the virtual memory of the system. It is different from the real world mode and has the codes of 32 bit or 16 bits. For the protected mode ,the size the selector register becomes of 16 bits.When you enter any 16 bit value , it get into the selector register.

_________ variables are defined outside all functions and are accessible to any function

within their scope.

Answers

Answer:

Global Variables

Explanation:

A Global variable is a variable defined usually in the header that can be accessed by any part in a program.

However, this is not a good practice because anything in the program can modify the value of the variable; also, helps to get more difficult to read a code, due to the fact that you need to know where are those variables and where they have been modified.

Example en c++: Check that the final result its 10, it is not necessary to pass the variable as a parameter in functions

#include <iostream>

int varGlobal = 5; // this is the global variable

void ChangeVarGlobal()

{

varglobal=10; // reference to the variable

}

void main()

{

std::cout << global << '\n'; // reference to a variable in a second function

  ChangeVarGlobal();

  std::cout << global << '\n';

  return 0;

}

What is meant when it is said that an exception is thrown?

Answers

Answer:

It is an error in the program that warns the users that something is wrong in the data they have entered

Explanation:

Null pointer exception, ArrayIndexOutOfBounds and arithmetic exception are some of the exception which can be thrown in a code segment. example if we use divide by zero then the exception to be used is arithmetic exception. Similarly we can also define our own conditions for throwing an exception using the keyword throw. Example throw exception class("error message"),

Consider the following line of code: price= input(Please enter the price: ") What would be the next line in your code that will allow you to store the price as a decimal number price price(decimal) price float(price) price decimal(price) price int(price

Answers

Answer:

price float(price)

Explanation:

There are four basic type of data type use in the programming to declare the

variable.

1. int:  it is used for integer values.

2. float:  it is used for decimal values.

3. char:  it is used for character values

4. Boolean: it is used for true or false.

in the question, the one option contain the data type float (price float(price)). So, it store the value in decimal.

price int(price):  it store the value in integer.

price decimal(price):  it is wrong declaration of variable. their is no data type in the programming which name is decimal.

price price(decimal):  it is wrong declaration of variable. their is no data type in the programming which name is price.

In the MOV instruction both operands i.e. source andthe destination cannot be

_______________ operands.

Answers

Answer:

an immediate.

Explanation:

It is because of the instruction encoding and decoding.Intel which make these instructions decided not include instructions which provide no real advantage. MOV segment register is one of them because segment register need not to be changed very often.This saves the space in instruction encoding.

Answer: In the MOV instruction both operands i.e., source and the destination cannot be immediate operands.

Explanation:

The destination operand must be in data alterable mode and it cannot be an an immediate operand, or a segment register. Basically, the mov operation are used to copy the values stored in one registers to another registers. It can be used to load a small integer in the register.

Windows XPProfessional and Windows Vista Both have same devicedrivers.
True
False

Answers

Answer: False

Explanation:

 Windows XP Professional and Windows Vista, both does not have same device drivers because they both have different structural modules. Both windows XP and windows Vista are different in terms of their security architecture, mobile computing and networking technologies.

As, windows XP has suffered from security problems or issues with the performance. Vista has received issue with product activation and performance. Another common problem of Vista is that integration of new form of DRM in the operating system and security technology.

Given the following Preorder and Inorder traversals, please recover the original tree. Preorder: C F D G H A B E Inorder: G D H F C B E A

Answers

Answer:

To build the original tree follow the steps described below:

In Preorder traversal the root always comes first in the list, so C is the root. In Inorder traversal the nodes those are left to C will be in left sub-tree of C and the nodes those are right to C will be in the right sub-tree of C.Now, in the left sub-tree (G D H F) , F comes first in the Preorder traversal, so F is the root. And as G D H are left to F in Inorder list so, they will be in left sub-tree of F. In the right sub-tree of C, (B E A),  A comes first in the Preorder list. So A is the root and B E will in left subtree of A.In left sub-tree of F, (G D H), D comes first in Preorder list, so D is the root and G is the left child of D and  H is the right child of D.Among (B E), B comes first in Preorder list, so B is the root and as E is right to B in Inorder, so is the right child of B

For more follow the diagram:

Explanation:

Preorder traversal visits the root of the tree first then the left sub-tree and then the right subtree.

Inorder traversal visits the left subtree first then the root and then the right subtree.

In a well-designed detail report, a field called a(n) ____ field controls the output.
Answer
break
indexed
dominant
control

Answers

Answer:

Control

Explanation:

In doing a load of clothes, a clothes drier uses 18 A of current at 240 V for 59 min. A personal computer, in contrast, uses 3.0 A of current at 120 V. With the energy used by the clothes drier, how long (in hours) could you use this computer to "surf" the Internet?

Answers

Answer:

11.76 hours or 11 hours 45 minutes

Explanation:

Given

[tex]Current\ for\ drier = I_d = 18A\\Voltage\ for\ drier=V_d=240V\\Time\ for\ drier=t_d=59\ min[/tex]

We have to convert minutes into hours

So,

[tex]t=\frac{59}{60} = 0.98\ hours[/tex]

[tex]Current\ for\ Computer=I_c=3.0A\\Voltage\ for\ computer=V_c=120V[/tex]

As we are given that we have to find the time the computer will sustain using the same energy as the drier. So,

[tex]I_d*V_d*t_d=I_c*V_c*t_c\\18*240*0.98=3*120*t_c\\t_c*360=4233.6\\t_c=\frac{4233.6}{360}\\ t_c=11.76\ hours[/tex]

Converting into minutes will give us: 11 hours 45 minutes

Therefore, with the same energy used by the drier, the computer can be used 11.76 hours to surf the internet ..

Which of the following would be considered a good name for a function that converts temperatures from Fahrenheit to Celsius? A. calc B. convert temp C. temp D. myfunction

Answers

Answer:B) converttemp

Explanation:  A good function name should provide an indication of the task carried out by the function.In this case, our task is related to conversion of temperature from one unit to another. So converttemp would represent a good nomenclature for the function and would enable the end user to determine the applicability of the function to his use case.

True / False
Overflow is usually ignored in most computer systems.

Answers

Answer: True

Explanation: Overflow in computer system is a situation when there is the occurrence of error or disruption due to very large number that is given for calculation cannot be handled.So whenever the range of the particular number given by the user for calculation exceeds is termed as overflow error.It is usually avoided by the computer system because there is not much input given with large numbers for arithmetic operation or can be handled.

. Stress can affect not only your health, but also other aspectsof your
life. What else can be affected by stress?
a. Family relationships
b. Work performance
c. Your attention to safety
d. All of the given options

Answers

Answer:

d

Explanation:

all of this. all of this can happen due to stress

What error occurs in the following program? #include using namespace std; int main() { int number1, number2, sum; cout << "Enter number 1:"; cin >> number1; cout << "Enter number 2:"; cin >> number2; number1 + number2 = sum; cout << "The sum of number 1 and number 2 is " << sum; return 0; }

Answers

Answer:

1. ‘cout’ was not declared in this scope.

2. ‘cin’ was not declared in this scope.

3. lvalue required as left operand of assignment.

Explanation:

The code gives the error cout and cin was not declare. This error means, we not include the library where they define.

cout and cin is the input/output instruction and they include in the library iostream file.

the last error is lvalue required as left operand of assignment.

lvalue means the assignable value, we actually do the wrong assignment.

number1 + number2 = sum;

here, sum is is the assignment variable. so, it must be in the right side of the '=' operator.

sum = number1 + number2 ;

Now, the above is correct. the value number1 plus number2 is assign to sum.

True of False - use T or F An interface is compiled into a separate bytecode file (.class).

Answers

Answer:

T

Explanation:

An interface is compiled to a separate bytecode class file.

For example of out application has a class myClass.java and an interface myInterface.java:

class myClass{

   String name;

   int age;

}

interface myInterface{

  public String getName();

  public int getAge();

}

Both of these are compiled to their own respective class files by the compiler,namely, myClass.class and myInterface.class.

Failing to include a complete ____ on each side of an && operator in an if statement is a common error in Java programming.

a.
operator

b.
mathematical expression

c.
variable

d.
Boolean expression

Answers

Answer:

Boolean expression

Explanation:

The operator '&&' is called AND operator. it provide the output base on the Boolean value on each side of AND operator.

it has four possible values:

First Boolean is TRUE and Boolean is TRUE, then result will be TRUE.

First Boolean is TRUE and Boolean is FALSE, then result will be FALSE.

First Boolean is FALSE and Boolean is TRUE, then result will be FALSE.

First Boolean is FALSE and Boolean is FALSE, then result will be FALSE.

Therefore, the correct option is Boolean expression.

Write a function def countWords(stri ng) that returns a count of all words in the string string. Words are separated by spac For example, countWords ("Mary had a little lamb") should return 5.

Answers

Answer:

def w_count(s):

   return(len(s.split()))

st=input('Enter a string:')    

print("Number of words in given string=",w_count(st))

Explanation:

Write a C++ programthat simulates a cash register. The user should keeptyping

in the prices of items andthe register must keep adding them up. When the user

types a 0, the registershould add up the prices of all the items, add 8% salestax,

and output the finaltotal. Example output is given below.


Enter the price of item 1: 5.00

Answers

Answer:

//C++ code for the cash register..

#include <iostream>

#include<vector> //including vector library

using namespace std;

int main() {

vector<float> cash; //declaring a vector of type float.

float item=2,cash_sum=0;

int counter=1;

while(item!=0)//inserting prices in the vector until user enters 0...

{

    cout<<"Enter the price of item "<<counter<<" :"<<endl;

cin>>item;

counter++;

cash.push_back(item);//inserting element in the vector...

}

for(int i=0;i<cash.size();i++)//looping over the vector...

{

    cash_sum+=cash[i];//summing each element..

}

cash_sum*=1.08;//adding 8% sales tax.

cout<<cash_sum;//printing the result....

return 0;

}

Explanation:

I have taken a vector of type float.

Inserting the price of each item in the vector until user enters 0.

Iterating over the vector for performing the sum operation.

Then after that adding 8% sales tax to the sum.

Printing the output at last.

Final answer:

A C++ program simulates a cash register by adding prices entered by the user, ending with a zero input to calculate and output the total with an added 8% sales tax.

Explanation:

The task is to create a C++ program that acts as a cash register, adding up the prices of items entered by the user. When the user enters a zero, the program calculates the total cost including an 8% sales tax and displays it. Below is an example of how this can be implemented:

#include
#include
using namespace std;
int main() {
   double price, total = 0.0;
   int count = 1;
   cout << fixed << setprecision(2);
   while (true) {
       cout << "Enter the price of item " << count << ": ";
       cin >> price;
       if (price == 0) break;
       total += price;
       count++;
   }
   double salesTax = total * 0.08;
   double finalTotal = total + salesTax;
   cout << "Final total after tax: $" << finalTotal << endl;
   return 0;
}

In this program, we use count to keep track of how many items have been entered and total to keep a running sum. The user is prompted for the price of each item, which is added to the total. If the user enters 0, the loop breaks, and the program calculates and outputs the final total, including the sales tax.

The code calculates and prints the sum of all the elements in the array a.

Int sum = 0;

For ( int I = 0; I < a.length; i++ )

{

//Your code goes here.

}

System .out.println( %u201Csum is %u201C + sum );

Answers

Answer:

public class sum{

    public static void main(String []args){

       int sum = 0;

       

       int[] a = {9,2,8,4,0,6};

       

       for ( int i = 0; i < a.length; i++ )

       

       {

       

           sum = sum + a[i];    

       

       }

       System.out.println("The sum is: "+sum );

   }

}

Explanation:

First create the class in java programming.

Then create the main function and declare the variable and array.

To calculate the sum of all element in array, first we have to traverse the array pick element one by one and then add,

so, we have to use loop for traversing and add with sum which inialize with zero.

suppose array element is 1,2,3,4

sum = sum +a[1]  means sum = 0 +1=1

the sum = 1+2=3, sum = 3+4=7.

and then finally print the result store in sum.

What is the output of the following code segment?

n = 1;
for ( ; n <= 5; )
cout << n << ' ';
n++;




1. 1 2 3 4 5

2. 1 1 1 ... and on forever

3. 2 3 4 5 6

4. 1 2 3 4

5. 2 3 4 5

Answers

Answer

1 2 3 4 5

Explanation:

initialize the value of n with 1

then, for loop is executed until the condition is true.

so, it check the condition 1<=5, condition true, code is executed and print 1

and n become 2.

again check condition 2<=5 condition true, code is executed and print 2

and n become 3.

and so on....

it print 1 2 3 4 5 after that check condition 6<=5 condition false, it terminate from loop.

Therefore, the answer is  1 2 3 4 5

Other Questions
A gas is most likely to exist at which of the following conditions?A) High temperatures and high pressuresB) High temperatures and low pressuresC) Low temperatures and high pressuresD) Low temperatures and low pressures NEED HELP ASAP!!!Choose the best explanation of codominance. A. Genes are blended during homologous recombination. B. In a heterozygote, both alleles are expressed. C. In a heterozygote, both alleles combine to form an intermediate phenotype. D. A heterozygote is considered a carrier for the recessive allele. Please help! 50 points! (7z^3+42z^2-15z+1)- (36z^2+12z-21) F(x)=3x+1 and g(x)= x^2-6 find (fg)(x) Wendy is paid $12 per hour and plans to work between 30 and 35 hours per week. Identify the independent and dependent quantity in the situation. Find reasonable domain and range values.weekly pay; hours worked; 30 to 35 hours; $360 to $420hours worked; weekly pay; 30 to 35 hours; $0 to $420hours worked; weekly pay; 30 to 35 hours; $360 to $420weekly pay; hours worked; $360 to $420; 30 to 35 hours; Need some help ya plz The graph shows the relationship between the price of frozen yogurt and the number of ounces of frozen yogurt sold at different stores and restaurants I need help pretty please! In a certain cyclotron a proton moves in a circle of radius 0.740 m. The magnitude of the magnetic field is 0.960 T. (a) What is the oscillator frequency? (b) What is the kinetic energy of the proton? HELP!Select the correct answer.Two equal spheres with the maximum possible radius are carved out of a right cylinder.Find the ratio of the volume of one sphere to the volume of the right cylinder.A. 1 : 1B. 1 : 3C. 2 : 3D. 3 : 1 What is the effect on the equilibrium price and equilibrium quantity of magazinesmagazines if the price of a newspapera newspaper decreasesdecreases and the wage rate paid to magazine production workersmagazine production workers decreasesdecreases? The equilibrium price of a magazinea magazine ______ and the equilibrium quantity ______. Which equation is used to help form the combined gas law? Genesis Scents has two divisions: the Cologne Division and the Bottle Division. The Bottle Division produces containers that can be used by the Cologne Division. The Bottle Division's variable manufacturing cost is $3.10, shipping cost is $0.21, and the external sales price is $4.10. No shipping costs are incurred on sales to the Cologne Division, and the Cologne Division can purchase similar containers in the external market for $3.70. The Bottle Division has sufficient capacity to meet all external market demands in addition to meeting the demands of the Cologne Division. Using the general rule, the transfer price from the Bottle Division to the Cologne Division would be: Which of the following best describes the use of a renewable resource? Most power plants burn fossil fuels to generate electricity for use in homes and offices. Natural gas is extracted from deep in the Earth and piped to customers to use for cooking. Water falls through openings in a dam turning turbine blades that generate electricity. We use gasoline to power our cars to get to work and school each day. Determine if a triangle with side lengths 8, 14, and 15 is acute, right, or obtuse correct the five highlighted areas by fixing the punctuation and words If f(x) = -2x - 5 and g(x) = x^4 what is (gf)(-4) El rea de Mxico es casi dos veces el rea de Texas.ciertofalso Escoge las palabras que son argentismos-Re-bonito-Mate-Ceviche-Azteca-Pibe-Tortilla-Piba -Lompa-Salsa-Como andas-Tango -Merengue-Milanesa -Guacho-Comadre-Choripan