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
Nadusha1986 [10]
3 years ago
5

Discuss a situation in which you might want to use a floating-point number with a fractional part for a loop control variable. W

hat are the pitfalls of using real numbers for the index variable in a for loop?
Computers and Technology
1 answer:
serious [3.7K]3 years ago
7 0

Answer:

1. When calculating the division of each number in some range of floating type number.

2. One cannot use real numbers for exact comparison. Two real numbers are rarely equal. Real numbers are have representational errors.

Explanation:

1. In structured programming, we make use of a floating-point number with a fractional part for a loop control variable. a given scenario is when we just want to calculate the division of each number in some range of floating type number. However, the downsides to using a floating-point number with a fractional part for a loop control variable are:

  • They can cause 'off-by-one' failure
  • A floating point number cannot represent all simple fractions exactly

2. The pitfalls of using real numbers for the index variable in a for loop:

  • Two real numbers are hardly equal
  • One cannot use real numbers for exact comparison
  • The existence of representational errors
You might be interested in
ProcessName2
RoseWind [281]

Explanation:

This is easily solvable with a for loop. Something like:

(I assume c++)

#include <iostream>

#include <string>

int main() {

take_input: //tag

std::string input;

cin >> input; //take the input

int spaceCount = 0;

char checking;

for(unsigned int i = 0; i == input.length(); ++i) {

checking = spaceCount[i];

if(checking == ' ')

spaceCount++;

}

if(spaceCount >= 1 && input.length >= 5)

std::cout << "Your name is " + input;

else

goto take_input; // reasks for input if the conditions are not met

return 0;

};

**remove all spaces before using the code, the if statements are messed up

5 0
3 years ago
9.10: Reverse ArrayWrite a function that accepts an int array and the array ’s size as arguments . The function should create a
AleksandrR [38]

Answer:

#include <iostream>

using namespace std;

int * reverse(int a[],int n)//function to reverse the array.

{

   int i;

   for(i=0;i<n/2;i++)

   {

       int temp=a[i];

       a[i]=a[n-i-1];

       a[n-i-1]=temp;

   }

   return a;//return pointer to the array.

}

int main() {

   int array[50],* arr,N;//declaring three variables.

   cin>>N;//taking input of size..

   if(N>50||N<0)//if size greater than 50 or less than 0 then terminating the program..

   return 0;

   for(int i=0;i<N;i++)

   {

       cin>>array[i];//prompting array elements..

   }

   arr=reverse(array,N);//function call.

   for(int i=0;i<N;i++)

   cout<<arr[i]<<endl;//printing reversed array..

   cout<<endl;

return 0;

}

Output:-

5

4 5 6 7 8

8

7

6

5

4

Explanation:

I have created a function reverse which reverses the array and returns pointer to an array.I have also considered edge cases where the function terminates if the value of the N(size) is greater than 50 or less than 0.

8 0
2 years ago
Explain the following as used in Tally Accounting Software:
vaieri [72.5K]
Business transactions
3 0
2 years ago
What is output in computer?​
Goryan [66]

Answer:

An output is data that a computer sends. An input device is something you connect to a computer that sends information into the computer. An output device is something you connect to a computer that has information sent to it.

Output is defined as the act of producing something, the amount of something that is produced or the process in which something is delivered. An example of output is the electricity produced by a power plant. An example of output is producing 1,000 cases of a product.

3 0
2 years ago
What would happen if technology no longer existed? How would it change education? Select three options.
PSYCHO15rus [73]

Answer:

answer 4

Explanation:

no technology, no computers, no computers= paper and paper= handwriting :-)

6 0
1 year ago
Other questions:
  • In addition to regular watch features, which two features are often found on smart watches?
    13·1 answer
  • There are information that are in the web view source that may not appear on the web page such as meta name. In addition there c
    6·1 answer
  • When transporting data from real-time applications, such as streaming audio and video, which field in the ipv6 header can be use
    12·1 answer
  • Write a program to calculate and return total surface area of a box using FUNCTION _END FUNCTION.​
    15·1 answer
  • Website administrators relay on ______, which is data such as the number of users who commented on, shared, viewed, or liked web
    7·2 answers
  • Software that was designed to serve the needs of a specific company or organization is called:
    11·1 answer
  • When you expand the virtual size of a game, what do you create?
    7·1 answer
  • If you pay a subscription fee to use an application via the internet rather than purchasing the software outright, the app is ca
    13·1 answer
  • MR. Tom asked her students could they plant a flower and bring it to class. Sarah brought his flower and said it was a rose. Jam
    6·1 answer
  • True or False, In adversarial searching, agents using the MiniMax algorithm always select the state that has the highest guarant
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!