#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <math.h>
#include <string.h>
#define PI 3.141592654
load();
main()
{
int i = 1;
int Reuse;
int Opt;
float Num1, Num2 ,ans;
char oper;
while (i < 20){
load();
i++;
}
printf("Loading done!!");
Sleep(2000);
system("cls");
printf("Welcome to our calculator.\n");
Reuse = 1;
while (Reuse == 1){
printf("\n\nWhich mode do you want to use?\n1.Normal maths operations\n2.Trigonometric functions\n3.Exit\nYour input: ");
scanf("%d", &Opt);
if (Opt == 1){
printf("Your two numbers: ");
scanf("%f%f", &Num1, &Num2);
printf("Your operation symbol: ");
scanf(" %c", &oper);
if (oper == '+'){
ans = (Num1 + Num2);
printf("Here is your answer:\n%f %c %f = %.5f (To 5 decimal places)\n\n", Num1, oper, Num2, ans);
Sleep(2450);
} else if (oper == '-'){
ans = (Num1 - Num2);
printf("Here is your answer:\n%f %c %f = %.5f (to 5 decimal places)\n\n", Num1, oper, Num2, ans);
Sleep(2450);
} else if (oper == '/'){
ans = (Num1 / Num2);
printf("Here is your answer:\n%f %c %f = %.5f (to 5 decimal places)\n\n", Num1, oper, Num2, ans);
Sleep(2450);
} else if (oper == '*'){
ans = (Num1 * Num2);
printf("Here is your answer:\n %f %c %f = %.5f (to 5 decimal places)\n\n", Num1, oper, Num2, ans);
Sleep(2450);
} else if (oper == '^'){
ans = (pow (Num1 , Num2));
printf("Here is your answer:\n %f %c %f = %.5f (to 5 decimal places)\n\n", Num1, oper, Num2, ans);
Sleep(2450);
} else{
printf("\n\nYour input operator is incorrect; ERROR 1 Sintek");
Sleep(2450);
system("cls");
}
}
if (Opt == 2){
printf("Input your angle in degrees: ");
scanf("%f", &Num1);
printf("The trigo you are going to use\ns for sine\nc for cosine\nt for tangent\nYour input: ");
scanf(" %c", &oper);
if (oper == 's'){
ans = (sin (Num1 * PI/180));
printf("\nHere is your answer:\nAngle: %f\nSin%f = %f", Num1, Num1, ans);
Sleep(2450);
} else if (oper == 'c'){
ans = (cos (Num1 * PI/180));
printf("\nHere is your answer:\nAngle: %f\nCos%f = %f", Num1, Num1, ans);
Sleep(2450);
} else if (oper == 't'){
ans = (tan (Num1 * PI/180));
printf("\nHere is your answer:\nAngle: %f\nTan%f = %f", Num1, Num1, ans);
Sleep(2450);
} else{
printf("\n\nWrong operator used for Trigo; ERROR 1 Sintek");
}
}
if (Opt == 3){
printf("Thank you for visiting my calculator, wish you come back soon!!");
Sleep(3990);
system("cls");
exit(0);
}
}
}
load(){
system("cls");
printf("\\ LOADING /");
Sleep(15);
system("cls");
printf("| LOADING -");
Sleep(15);
system("cls");
printf("/ LOADING \\");
Sleep(15);
system("cls");
printf("- LOADING |");
Sleep(15);
system("cls");
printf(" LOADING ");
Sleep(3);
system("cls");
}
the above is my code. when running the power function, the pow()
in one of the if-else loop which is inside of the while loop, isnt outputing any numerical values, not even a incorrect number, but a phrase : 1.#Info
. other than that the code functions properly and smoothly. If you guys have any improvements to make my code outstanding, please state too.
Which mode do you want to use?
1.Normal maths operations
2.Trigonometric functions
3.Exit
Your input: 1
Your two numbers: 432 543
Your operation symbol: ^
Here is your answer:
432.000000 ^ 543.000000 = 1.#INF0 (to 5 decimal places)
float
?long double
., but even that may not be enough.float
yet callsdouble
functions likesin(),tan(), pow()
UnfreeHeX, What C compiler are you using?PI
such as 3.1415926535897932384626433832795. No harm to have an overly precise constant in code.