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
shutvik [7]
4 years ago
8

Which of the following is an example of a logic bug?

Computers and Technology
1 answer:
Lunna [17]4 years ago
5 0
Missing parenthesis would be a logic bug because it results in the wrong answer being generated by the compiler.  
You might be interested in
Write a C++ program to find if a given array of integers is sorted in a descending order. The program should print "SORTED" if t
LenKa [72]

Answer:

The cpp program for the given scenario is as follows.

#include <iostream>

#include <iterator>

using namespace std;

int main()

{

   //boolean variable declared and initialized  

   bool sorted=true;

   //integer array declared and initialized

   int arr[] = {1, 2, 3, 4, 5};

   //integer variables declared and initialized to length of the array, arr

   int len = std::end(arr) - std::begin(arr);

       //array tested for being sorted

    for(int idx=0; idx<len-1; idx++)

    {

        if(arr[idx] < arr[idx+1])

           {

               sorted=false;

            break;

           }

    }

    //message displayed  

    if(sorted == false)

     cout<< "UNSORTED" <<endl;

 else

    cout<< "UNSORTED" <<endl;

return 0;

}

OUTPUT

UNSORTED

Explanation:

1. An integer array, arr, is declared and initialized as shown.

int arr[] = {1, 2, 3, 4, 5};

2. An integer variable, len, is declared and initialized to the size of the array created above.

int len = std::end(arr) - std::begin(arr);

3. A Boolean variable, sorted, is declared and initialized to true.

bool sorted=true;  

4. All the variables and array are declared inside main().

5. Inside for loop, the array, arr, is tested for being sorted or unsorted.  The for loop executes over an integer variable, idx, which ranges from 0 till the length of the array, arr.

6. The array is assumed to be sorted if all the elements of the array are in descending order.

7. If the elements of the array are in ascending order, the Boolean variable, sorted, is assigned the value false and for loop is exited using break keyword. The testing is done using if statement.

8. Based on the value of the Boolean variable, sorted, a message is displayed to the user.

9. The program can be tested for any size of the array and for any order of the elements, ascending or descending. The program can also be tested for array of other numeric data type including float and double.

10. All the code is written inside the main().

11. The length of the array is found using begin() and end() methods as shown previously. For this, the iterator header file is included in the program.

4 0
3 years ago
What is the process in which a server is partitioned into smaller components
Usimov [2.4K]
I believe the answer to this is server virtualization.
4 0
4 years ago
Which element is located on the top left of the Word screen?
victus00 [196]
The <span>element located on the top left of the Word screen is the Quick Access Toolbar.  </span>On the quick access toolbar, you can find some of the common functions that you will need to use on a regular basis, it contains commands that are used most often, for example Redo, Undo and Save etc.
7 0
3 years ago
Are there any easy questions on Brainly?
icang [17]
If you want to answer easy questions click on answer at the bottom of your screen and then look at the top and click on school and choose a school (for example choose middle school because people have posted way questions) :)
6 0
3 years ago
Read 2 more answers
Which image file format is the most widely used?
Ostrovityanka [42]

Answer: jpeg because its a lot of people use it for quaity

7 0
2 years ago
Other questions:
  • Why might you need to convert a file to another file type?
    14·1 answer
  • What causes air pollution in your community?
    13·1 answer
  • Describe the 3 parts of a spreadsheet formula
    12·1 answer
  • Basic fortran c++ c# and java are all ____ languages
    11·1 answer
  • Why is ipsec considered to be a transparent security protocol?
    6·1 answer
  • If Nancy receives an encrypted message from Matthew, which key does she use to read it? Nancy’s private key Nancy’s public key M
    8·1 answer
  • Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a n
    7·2 answers
  • For what reason can security risks never be fully eliminated?​
    7·1 answer
  • Hello im looking for someone to answer my question. Its about a coding project called "Quiz Master". Im having trouble with the
    7·1 answer
  • Spam is _____.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!