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
galben [10]
3 years ago
13

What is the output of the following program? #include using namespace std; class TestClass { public: TestClass(int x) { cout &lt

;< x << endl; } TestClass() { cout << "Hello!" << endl; } }; int main() { TestClass test; return 0; }
Computers and Technology
1 answer:
Lunna [17]3 years ago
6 0

Answer:

The answer is "Hello!".

Explanation:

  • In the given C++ language program, a class "TestClass " is defined, which contains a parameterized constructor and default constructor.
  • In the parameterized constructor an integer variable "x" is passed in the constructor parameter and inside a constructor parameter value is print. Inside the default constructor, a print function (cout) is used that print message "Hello!".
  • In the main method, a class "TestClass" object is created that is "test" when a class object is created it automatically called a default constructor that's why the output to this code is "Hello!".

You might be interested in
Calculate the maximal size of a file if we have:
ollegr [7]

Answer:

4 GB

Explanation:

<u>Determine the maximal size of a file </u>

100 direct block address

= 100 * 1024 = 102400

One single indirect block address

= 128 * 1024 = 131072

One double indirect block address

= 128 * 128 * 1024 = 16777216

one triple indirect block address

=  128 * 128 * 128 * 1024 = 2147483648

one quadruple indirect block addresses

=  128 * 128 * 128 * 128 * 1024 = 274877906944

maximal size of the file

= ∑ 102400 +  131072 + 16777216 + 2147483648 + 274877906944

= 4GB

7 0
3 years ago
python A pet shop wants to give a discount to its clients if they buy one or more pets. The discount is equal to 20 percent of t
Artyom0805 [142]

Answer:

The following are the program in the Python Programming Language.

#define function

def discount(prices, isPet, nItems):

 # declare and initialize variables to 0

 i = 0

 cost = 0

 pets = 0

 item = 0

 item_Cost = 0

 #set the while loop

 while(i < nItems):

   #check the items of the variable

   if isPet[i]:

     #add and initialize in the cost

     cost += prices[i]

     #increament in the variable by 1

     pets += 1

   #otherwise

   else:

     #add and initialize in the item_Cost

     item_Cost += prices[i]

     #increament in the variable by 1

     item += 1

   #then increment in the variable by 1

   i += 1

 #check the pet is greater than equal to 1  

 #and item is greater than equal to 5

 if(pets >= 1 and item >=5):

   #then, print the message

   print("You receive discount")

   #set discount of the items

   discount = 0.2 * item_Cost

   # calculate bill after deducting discount

   bill = cost + item_Cost - discount

   #print the bill

   print("Final Bill amount is", bill)

 #otherwise

 else:

   #print the message

   print("You do not receive any discount")

   #calculate bill without deducting discount

   bill = cost + item_Cost

   #print the final bill

   print("Final Bill amount is", bill)

#set empty list type variables

price = []

pet = []

#set the infinite loop

while True:

 #get input from the user

 sprice = int(input("Enter the price (-1 to quit): "))

 #check that price is not equal to the -1

 if(sprice != -1):

   #add price in the list

   price.append(sprice)

   #ask for choice from the user

   choice = input("Is it a pet (Y / N)? ")

   #check the choice of the user is y or Y

   if(choice == 'Y' or choice == 'y'):

     # then, add in the pet

     pet.append(True)

   #otherwise

   else:

     #not add in the pet

     pet.append(False)

   print("")

 #break the loop

 else:

   break

#declare variable that store the length

items = len(price)

#call and initialize the variable

discount(price, pet, items)

<u>Output</u>:

Enter the price (-1 to quit): 96

Is it a pet (Y / N)? y

Enter the price (-1 to quit): 69

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 41

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 52

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 96

Is it a pet (Y / N)? n

Enter the price (-1 to quit): 74

Is it a pet (Y / N)? n

Enter the price (-1 to quit): -1

You receive discount

Final Bill amount is 361.6

Explanation:

<u>The following are the description of the program</u>.

  • Firstly, define the function 'discount()' and pass the arguments 'prices', 'isPet' and 'nItems' in its parameter.
  • Then, declare and initialize the variables 'i' to 0, 'item_Cost' to 0
  • , item to 0, 'cost' to 0 and 'pets' to 0.
  • Then, set the while loop to add the price of the items and the cost of the pets.
  • Set the if-else conditional statement to check the pet is greater than equal to 1 and the items are greater than equal to 5 then, set the discount and print the bill after deduction.
  • Otherwise, print the bill without deduction.
  • Finally, set two list type variable then, set the infinite while loop that gets input from the user and check that the variable is not equal to -1 then append the data in the list then again check the user input then append in pet otherwise not append in pet and break the loop. Then, set the variable that stores the length of the price and call the following function by passing arguments in its parameter.
8 0
3 years ago
What do you understand by storage devices ? Name any two storage devices.​
MatroZZZ [7]

Answer:

Types of storage devices

Primary Storage: Random Access Memory (RAM) Random Access Memory, or RAM, is the primary storage of a computer. ...

Secondary Storage: Hard Disk Drives (HDD) & Solid-State Drives (SSD) ...

Hard Disk Drives (HDD) ...

Solid-State Drives (SSD) ...

External HDDs and SSDs. ...

Flash memory devices. ...

Optical Storage Devices. ...

Floppy Disks.

6 0
3 years ago
Read 2 more answers
Numdu
gizmo_the_mogwai [7]
The question is unclear /unfinished please send again.
4 0
3 years ago
Media has scientifically been linked to media messages, as in the cause and effect theory. True or False?
padilas [110]

Answer:

true

this ans is not 100% correct but it may help you

4 0
3 years ago
Other questions:
  • Typohunting is registering a domain name that is similar to a trademark or domain name but that is slightly misspelled in hopes
    5·1 answer
  • 3. Which of the following statements is true of a time management plan? 35 POINTS
    9·2 answers
  • Describe one type of technology that is useful in producing images from space.
    9·1 answer
  • It is important to verify internet source because-------- choose that apply. A.the source should be written by real author. B.an
    6·2 answers
  • For the function definition int SomeFunc( /* in */ int alpha, /* in */ int beta ) { int gamma; alpha = alpha + beta; gamma = 2 *
    6·2 answers
  • This week you will learn about basic code structure. The term structure, as it relates to programming, refers to the decisions y
    14·1 answer
  • You must. place a child in a federally approved child restraint device. if the child is
    5·2 answers
  • If, when asked for a date of birth, the user enters a future date, this error should be caught by a ________ check.
    8·1 answer
  • Project: big research project
    15·2 answers
  • What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.e
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!