Question

In: Computer Science

(1) What are the advantages and disadvantages to using the int data type rather than the...

(1) What are the advantages and disadvantages to using the int data type rather than the bool data type to manipulate Boolean expressions? Why do students think the int data type is still used for Boolean expressions?

(2) Discuss how C++ provides two-way selection through the if…else statement. Explain the syntax of this statement. Also, explain how the bool data type is used in C++ to manipulate Boolean expressions.

Solutions

Expert Solution

Answer 1

   The data type int is used over boolean

       1)   It results boolean true for a non-zero integer value.
       2)   It results boolean false for a zero integer value.

   Advantages
       1)   The counting can be operated along with boolean execution

           For example -

               int count = 10;
               if (count)
                   cout << count;
               else
                   cout << "zero";

           Gives the number as a result, and when it is zero it prints zero.

       2)   Arithmetic operation too can be performed over int.

Answer 2

   A two-way selection is -

       if (true)
       then
           //   do something
       else
           //   do something else

   Here, two choices are available to the user, whether it will be true or false.
   For every choice, there is a selection


Related Solutions

What are the advantages and disadvantages of using ranks rather than continuous measurements to conduct tests...
What are the advantages and disadvantages of using ranks rather than continuous measurements to conduct tests of hypotheses?
1. What are the advantages and disadvantages of investing with an investment company rather than buying...
1. What are the advantages and disadvantages of investing with an investment company rather than buying securities directly?
What are 4 advantages and 4 disadvantages of collective funds rather than individuals investing on their...
What are 4 advantages and 4 disadvantages of collective funds rather than individuals investing on their own?
1- What are the advantages and disadvantages for using doughnut chart? 2- What type of insights...
1- What are the advantages and disadvantages for using doughnut chart? 2- What type of insights can you gain from a contingency table that contains three variables that you cannot gain from a contingency table that contains two variables?
What are the advantages of a using a linked list rather than a conventional array in...
What are the advantages of a using a linked list rather than a conventional array in Java? and when would it be more efficient to use an array rather than a linked list? Explain your answer.
What are the advantages and disadvantages of using Electronic Data Interchange?
What are the advantages and disadvantages of using Electronic Data Interchange?
1. What are the advantages and disadvantages of using interview techniques to collect data? 2. What...
1. What are the advantages and disadvantages of using interview techniques to collect data? 2. What are the benefits of sampling? 3. You want to collect eating behavior information about preschool youth, elementary youth, adolescents and young adults. Consider the characteristics of these groups and decide how and where you might collect this information from each of these groups
What are the advantages and disadvantages of using interview techniques to collect data for a health...
What are the advantages and disadvantages of using interview techniques to collect data for a health needs assment program? Two paragraghs
Explain three advantages and three disadvantages of investing in mutual funds rather than directly investing in...
Explain three advantages and three disadvantages of investing in mutual funds rather than directly investing in assets such as stocks and bonds.
What are some advantages and challenges of using a logic-driven analytics process rather than follow a...
What are some advantages and challenges of using a logic-driven analytics process rather than follow a data-driven analytics process??
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT