well the other day i noticed that the diferance between 2 perfect squares is a prime number, so i made a program that does the math for you.
yeah i couldnt get a "yes/no would you like to do it again" thing to work, so i just made it loop like that.Code:#include<iostream> using namespace std; int counter = 1; int main() { int num1; do { cout << "enter a number: "; cin >> num1; int num2 = num1 + 1; int square1 = num1 * num1; int square2 = num2 * num2; int prime = square2 - square1; cout << "your prime number is: " << prime << endl; } while (counter = 1); cin.get(); return 0; }
also, dont try to enter a letter, it spazzes out.![]()



LinkBack URL
About LinkBacks





lol