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
mariarad [96]
3 years ago
12

What are the purpose of each in c++?

Computers and Technology
1 answer:
34kurt3 years ago
6 0

<u>If statements</u>- This statement is used to check the condition.

    if(condition)

      {

        statement

     }

If the condition is true,then statement will run,else not.

<u>Switch statement</u>-This statement is used for long conditions.It is a substitute for if,else conditions

     switch(a)

       {

          case1: statement 1//if a=1

                      break;

          case2: statement 2 //if a=2

                       break;

         .....

          default:statement//if a is not equal to any of the cases.

<u>Multiway if</u>-In this statement ,if elseif and else were there.

    if(condition1)

       {

         statement 1

       }

   elseif(condition2)

       {

         statement 2

      }

..............

   else

       {

         statement n

       }

<u>Nested loops</u>-This statements are used when we use if-else conditions in other if,else conditions.

   if(condition 1)

     {

       if(condition 2)

          {

           if (condition 3)

              {

               statement 3

              }

          else

               {

                 statement 4

               }

           }

      ]

<u>rand()</u>-This method is used for generating random number.The expression is

     number=rand()%50;

It will generate a random number ranges between  0 to 50.

<u>srand()</u>-This method is used to set the starting value for random number series.

srand (time(NULL));

<u>seed()</u>-It is a method for initializing the same random series,it is passed in srand().

You might be interested in
The theory of plate tectonics evolved from previous theories and concepts put forward by several scientists before its conceptio
BlackZzzverrR [31]

Answer:

I. Continental drift.

Hope this helps

4 0
3 years ago
Read 2 more answers
A ____________would be a misconfiguration of a system that allows the hacker to gain unauthorized access, whereas a_____________
seraphim [82]

Answer:

The answer to this question is vulnerability and risk.

Explanation:

Vulnerability is there us misconfiguration in the system  and we know that our system is vulnerable means the hacker can gain unauthorized access to our system.

Risk is when there are chances that a misconfiguration  might happen in our system in future so that hacker could gain unauthorized access to the system.

7 0
3 years ago
Write a program in python that can compare the unit (perlb) cost of sugar sold in packages with different weights and prices. Th
Dmitrij [34]

Answer:

weight1 = float(input("Enter the weight of first package: "))

price1 = float(input("Enter the price of first package: "))

weight2 = float(input("Enter the weight of second package: "))

price2 = float(input("Enter the price of second package: "))

if weight1 > 0 and price1 > 0 and weight2 > 0 and price2 > 0:

   unit_cost1 = price1 / weight1

   unit_cost2 = price2 / weight2

   

   if unit_cost1 < unit_cost2:

       print("Package 1 has a better price.")

   else:

       print("Package 2 has a better price.")

else:

   print("All the entered values must be positive!")

Explanation:

*The code is in Python.

Ask the user to enter the weight and the price of the packages

Check if the all the values are greater than 0. If they are, calculate the unit price of the packages, divide the prices by weights. Then, compare the unit prices. The package with a smaller unit price has a better price.

If all the entered values are not greater than 0, print a warning message

8 0
3 years ago
Does anyone know how I can make this return a double with 2 decimal places?
dolphi86 [110]

hi :)   .,..............

Explanation:

8 0
3 years ago
An employee is paid at a rate of $16.78 per hour for the first 40 hours worked in a week. Any hours over that are paid at the ov
Ostrovityanka [42]

Answer:

Here is the C++ program:

#include<iostream>  // to use input output functions

using namespace std;  //to access objects cin cout

int main() {  //start of main function

int hrsWorked;  //stores the number of hours worked

   int dependents;  //stores the number of dependents

double grossPay;  //stores the gross pay

char choice;  //store the value for choice of user to continue

do {  //loop that keeps repeating as often as the user wishes

  cout<<"Enter number of hours worked in a week: ";  // prompts user to enter number of weeks

  cin>>hrsWorked;  //reads input value for number of hours worked

  cout<<"Enter number of dependents : "; // prompts user to enter number of dependents

  cin>>dependents;  //reads input value for number of dependents  

      if(hrsWorked>40)  //if hours worked are more than 40

       {grossPay = ((40 * 16.78) + (hrsWorked-40)*(16.78*1.5));  }  //employee is paid at the overtime rate of one and-one-half times

       else  //if hours worked are not more than 40

      { grossPay = (hrsWorked*16.78);}  // employee is paid at a rate of $16.78 per hour        

      double ssTax = 0.06* grossPay ;  //computes 6% Social Security tax withheld from gross pay

      double fIncomeTax = 0.14* grossPay;  //computes 14% federal income tax withheld from gross pay

      double sIncomeTax = 0.05 * grossPay;  //computes 5% state income tax withheld from gross pay      

   cout<<"worker’s pay: "<<grossPay<<endl;  //displays workers pay

   cout<<"worker’s gross pay after withholding amounts:"<<endl;  //displays workers pay including withholding amounts

   cout<<"withhold amount for state income tax is: "<<sIncomeTax<<endl;  //displays grosspay with state income tax withheld

   cout<<"withhold amount for social security tax is: "<<ssTax<<endl;  //displays grosspay with Social Security tax withheld

   cout<<"withhold amount for federal income tax is: "<<fIncomeTax<<endl;  //displays grosspay with federeal income tax withheld

   cout<<"withhold amount  for union dues is: $10 "<<endl;   // $10 per week is withheld for union dues

if(dependents >= 3) {  //if worker has three or more dependents

cout<<"withhold amount of $35 for health insurance "<<endl;

  grossPay = grossPay - 35;  }  //an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays  

    cout<<endl;  //prints a new line

    double take_homepay;  //stores the net take-home pay for the week.

    take_homepay = ((grossPay- ssTax- sIncomeTax - fIncomeTax) - 10);  //compute the net t ake-home pay for the week

cout<<"net amount take-home pay for the week is: "<<take_homepay;  //displays the net take-home pay for the week

    cout<<endl;  //prints a new line

cout<<"\nDo you want to continue? (press y to repeat or any key to quit)";  //ask user to repeat the calculation

cin>>choice;  //reads choice from user

cout<<endl;  //prints a new line

}while(choice =='y' || choice =='Y');  }   //loop continues to execute till user wants to repeat calculations and stops when user presses any key other than y or Y

Explanation:

The program works as follows:

Suppose number of working hours is 40 and number of dependents is 2

hrsWorked = 40

dependents = 2

if(hrsWorked>40) this condition evaluates to false because hrsWorked is equal to 40 so else part executes:

grossPay = (hrsWorked*16.78); this becomes:

grossPay = 40 * 16.78

grossPay = 671.2

double ssTax = 0.06* grossPay ;  this statement withholds 6% Social Security tax from gross pay. This becomes:

ssTax = 0.06* 671.2;

ssTax = 40.272

double fIncomeTax = 0.14* grossPay;  this statement withholds 14% federal income tax from gross pay. This becomes:

fIncomeTax = 0.14* 671.2;

fIncomeTax = 93.968

double sIncomeTax = 0.05 * grossPay;  this statement withholds 5% state income tax from gross pay. This becomes:

sIncomeTax = 0.05 * 671.2

sIncomeTax = 33.56

if(dependents >= 3) this condition is false because number of dependents is 2

Next to compute  net take-home pay the program control moves to the statement:

take_homepay = ((grossPay- ssTax- sIncomeTax - fIncomeTax) - 10)

this becomes:

take_homepay = ((671.2 - 40.272 - 33.56 - 93.968) - 10)

Note that the 10 here is the $10 per week which is withheld for union dues.

take_homepay = ((671.2 - 40.272 - 33.56 - 93.968) - 10)

take_homepay = 503.4 - 10

take_homepay = 493.4

The screenshot of the output of this program is attached.

8 0
4 years ago
Other questions:
  • Which programming component provides a temporary, named storage location in computer memory that cannot change during program ex
    6·1 answer
  • What type of address is the ip address 198.162.12.254/24?
    10·1 answer
  • Write an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the
    5·1 answer
  • What are the disadvantages of plasma display?
    9·1 answer
  • The level of competition is an important factor for many people when selecting a physical activity.
    7·2 answers
  • Question 1<br> REVPAR and REVPOR are basically the same thing.<br> True<br> False
    11·1 answer
  • Which computer network component connects two different networks together and allows them to communicate?
    8·2 answers
  • A __________ note is a private note that you leave for yourself or for other people who might use the presentation file
    9·1 answer
  • Nnbnnb dfhhfhfbhfbhdffd<br> ddbhfbhdhfbhdhf<br> hhffudjbfbjkd<br> dbhdfbhbfhdb
    10·1 answer
  • Why star topology is more reliable than bus or ring topologies
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!