code2pdf_675c5a2b08f34
code2pdf_675c5a2b08f34
//
#include <iostream>
#include<math.h>
#include<cstdlib>
#include< stdlib.h >//for system cls to clear screen
#include<conio.h>//for getch it waits for input from user befoer prociding
}
//the * function
float multi(float x) {
system("cls");
cout << " please only use 0-9 ,+ ,-, * ,/, ^, l (log)[x*log_a(b) , ! (factorial), r(root) : enter secound number" << endl << x << "*";
float y;
_getch();
cin >> y;
system("cls");
}
return x;
}
// the ^ function
float power(float x) {
system("cls");
cout << " please only use 0-9 ,+ ,-, * ,/, ^, l (log)[x*log_a(b) , ! (factorial), r(root) : enter secound number" << endl << x << "^";
float y;
_getch();
cin >> y;
system("cls");
cout << x << "^" << y;
//logarithmic function
float loga(float x)//log function
{
float b, y;
system("cls");
cout << " please only use 0-9 ,+ ,-, * ,/, ^, l (log)[x*log_a(b) , ! (factorial), r(root) : enter secound number" << endl << x << "* log_a(b) , enter a "
_getch();
cin >> y; // Value
if (y != 0 && b!=0 ) {
system("cls");
cout << x << "* log_" << b << "(" << y << ")";
// Calculate log_b(y)
float result = x * (log(y) / log(b)); // Change of base formula
_getch();
cout << "=" << result; // Output result
}
else
{
cout << " are you trying to make this pc blow up >:#" << endl;
}
return 0;
long fac = 1;
for (int i = 1; i <= x; i++) {
fac *= i;
}
cout << x << "!" ;
return fac;
}
float root(float x)//root of x
{
system("cls");
cout << "square root of " << x << "=";
int main()
{
int loop;
loop = 1;
while (loop > 0)
{
cout << "hello user my name is hamza shrief id:692400679 i will be your host today ;) "<<endl<< " please only use 0 - 9, +, -, *, / , ^, l(log)[x * log_a(b), !(fa
string tut;
if (loop < 2)//this make the message disaper from the secound time and onward : wow right! :O
{
cout << "do you want a tutorial y/n : ";
cin >> tut;
if (tut == "y")
{
system("cls");
cout << "Tutorial :use me like a normal calcualtor enter the first number then the desired opration , then the second number then hit enter for the res
}
else
{
system("cls");
cout << "hello user please only use 0-9 ,+ ,-, * ,/, ^, l (log)[x*log_a(b) , ! (factorial), r(root) " << endl;
}
}
float x;
_getch();
cin >> x;
system("cls");
cout << "hello user please only use 0-9 ,+ ,-, * ,/, ^, l (log)[x*log_a(b) , ! (factorial), r(root) : select opriation" << endl <<x ;
_getch();
string sympol;
cin >> sympol;
system("cls");
cout << x << sympol;
if (sympol == "+") {
sum(x);
}
else if (sympol == "-") {
min(x);
}
else if (sympol == "/") {
divide(x);
}
else if (sympol == "*") {
multi(x);
}
else if (sympol == "^") {
power(x);
}
else if (sympol == "l")
{
loga(x);
}
else if (sympol == "!") {
}
else
{
system("cls");
cout << "are you trying to kill me >;( dont use numbers over 13 in factorial " << endl << "Note:please use positve integer number thats less that 13 (due
}
}
else if (sympol == "r")
{
root(x);
}
else
{
cout << "are you trying to kill me >:( ? next time please use +,-,/,*,^,l,r,! ." << endl << "press enter to end";
return 1;
}
string answer;
cout << endl << " :do you want to restart ?? y/n ; " ;
cin >> answer;
if (answer == "y")
{
loop = 2;
system("cls");
}
else if (answer == "n")
{
cout << endl << "bye :)";
loop = 0;
}
else
{
cout << "error ending program :/ ";
loop = 0;
}
}
}
/*refrences note some of these i didnt implemnt and some are missing
https://www.reddit.com/r/cpp_questions/comments/ymtgom/i_recently_switched_from_c_to_c_and_this_code/?rdt=55329
https://cplusplus.com/forum/beginner/269832/
https://stackoverflow.com/questions/48736611/function-overload-with-c-using-vs2017
converting float to int
https://www.geeksforgeeks.org/how-to-convert-float-to-int-in-cpp/
how to see if float can be integer
https://cplusplus.com/forum/beginner/253997/
factorial
https://www.programiz.com/cpp-programming/examples/factorial
https://en.cppreference.com/w/cpp/header/type_traits
*/