The purpose of this program is to accept two numbers from the user, and figure out the two inputted numbers' factors and if they have any factors that are squares.
When I try to run it, it throws an error on the function call of conclusionaryOutput():
[cquery] address of function 'listSquares' will always evaluate to 'true' [-Wpointer-bool-conversion]
and:
use of undeclared identifier 'isASquare1'; did you mean 'listSquares'?
#include <iostream> using namespace std; void conclusionaryOutput(int number1, int number2, bool isASquare1, bool isASquare2){ if(isASquare1 == false && isASquare2 == false){ cout << "Therefore the ordered pair (" << number1 << "," << number2 << ") is SWEET." << endl; } else if(isASquare1 == false && isASquare2 == false){ cout << "Therefore the ordered pair (" << number1 << "," << number2 << ") is SOUR." << endl; } else if(isASquare1 == true && isASquare2 == false){ cout << "Therefore the ordered pair (" << number1 << "," << number2 << ") is SALTY." << endl; } else{ cout << "Therefore the ordered pair (" << number1 << "," << number2 << ") is BITTER." << endl; } } void listSquares(int divisor, int numOfSquares){ if (numOfSquares !=1){ cout << ", " << divisor; } else{ cout << divisor; } } void squareInquiry(int number1, int number2){ bool containSquareFactor1; bool containSquareFactor2; int counter; int divisor; int numOfSquares; counter = 2; while (counter <= 70){ divisor = counter * counter; if (number1 % divisor == 0){ numOfSquares++; listSquares(divisor, numOfSquares); } counter++; } if (numOfSquares > 0){ cout << number1 << " has these factors (>1) that are square: " << numOfSquares << endl; cout << number1 << "is not square-free" << endl; containSquareFactor1 = true; } else{ cout << number1 << " has these factors (>1) that are square: (none) " << endl; cout << number1 << "is square-free" << endl; containSquareFactor1= false; } counter =2; numOfSquares =0; while(counter <=70){ divisor = counter * counter; if (number2 % divisor == 0){ numOfSquares++; listSquares(divisor, numOfSquares); } counter++; } if(numOfSquares > 0){ cout << number2 << " has these factors (>1) that are square: " << numOfSquares << endl; cout << number2 << "is not square-free" << endl; containSquareFactor2 = true; } else{ cout << number2 << " has these factors (>1) that are square: (none) " << endl; cout << number2 << "is square-free" << endl; containSquareFactor2= false; } conclusionaryOutput(number1, number2, isASquare1, isASquare2); } int main(){ int firstInt; int secondInt; cout << "Enter the 1st integer of the pair, between 2 and 5000: "; cin >> firstInt; while(firstInt < 2 || firstInt > 5000){ cout << "Invalid entry, Please try again: "; cin >> firstInt; } cout << "Enter the 2nd integer of the pair, between 2 and 5000: "; cin >> secondInt; while(secondInt <2 || secondInt > 5000){ cout << "Invalid entry, Please try again: "; cin >> secondInt; } squareInquiry(firstInt, secondInt); return 0; } https://stackoverflow.com/questions/66538452/the-call-to-conclusionaryoutputnumber1-number2-isasquare1-isasquare2-is-t March 09, 2021 at 06:59AM
没有评论:
发表评论