Do you guys have any idea where I've gone wrong?

``````/*
Super Simple Calculator V3.0
- Created By FTProtocol
*/

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <windows.h>
#include <conio.h>

#define nl '\n'
#define PI 3.14159265
const double a=5;
const double b=3;
const double c=8;

int x,y,choice;
int ans=0;
char loop;
float div1;

int main()
{
double resSqrt, resSin, resCos, resTan, resQuad[1];
char boolSqrt='\0';

printf(" Welcome to SCC - V3.0");
Sleep(1500);
printf("\n    - Created by FTProtocol");
Sleep(5000);
system("cls");
printf(" Would you like to continue? (y/n): ");
scanf("%s",&loop);

if (loop =='y' || loop =='Y')
{
system("cls");
printf("\n -----------------------");

printf("\n\n Please enter the first number: ");
scanf("%i",&x);

printf("\n Please enter the second number: ");
scanf("%i",&y);

resSqrt = sqrt(x);
resSin = sin(x*PI/180);
resCos = cos(x*PI/180);
resTan = tan(x*PI/180);

system("cls");

printf("\n Select an operation.");
printf("\n 2. Subtraction");
printf("\n 3. Multiplication");
printf("\n 4. Division");
printf("\n 5. Square Root");
printf("\n 6. Sin");
printf("\n 7. Cos");
printf("\n 8. Tan");

scanf("%i",&choice);

switch(choice)
{
case 1 :
break;
case 2 :
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
case 6 :
break;
case 7 :
break;
case 8 :
break;
case 9 :
break;
default :
printf("\n Illegal operation selected");
break;
}
Sleep(1000);
printf(" Thanks for using SSC - Program will now restart!%c%c",nl,nl);
Sleep(3000);
system("cls");
}
else{
printf("\n Good-Bye :O %c%c",nl,nl);
getchar();
return 0;}

main();
return 0;
}``````

Error:

``error C2296: '^' : illegal, left operand has type 'const double'``

Lines:

``````resQuad[0] = (((-1)*b)+((b^2)-(4*a*c))^.5)/(2*a);
``resQuad[0] = (((-1)*b)+((b^2)-(4*a*c))^.5)/(2*a);``

This may not be the entire problem, but ^ is not the exponentiation operator in C++. It is the "Bitwise OR" operator. You may want to consider the pow function for exponentiation.
http://www.cplusplus.com/reference/clibrary/cmath/pow.html

It is the "Bitwise OR" operator.

Actually, it's the Bitwise XOR or exclusive-OR operator.
But you're right, the pow function should solve this compiler-error. Small example:

``````#include <iostream>
#include <math.h>

int main()
{
std::cout << pow(3.0,2) <<  "\n";
std::cin.get();
}``````

output: 9 (3^2)

commented: Yes, you are right. Good catch. +2

that would help me with basic exponents but with such a complex formula i dont think it will help....

I've tried many ways to use it but i really cant get it to work but please feel free to give me a little guidance on how to use it in conjunction with other parts of a formula.

it's easy, you have the formule, now convert it using pow(): `(-1*b)+(pow(b,2)-pow(4*a*c,0.5))/(2*a);` But I prefer to write it like this: `(-1*b)+(pow(b,2)-sqrt(4*a*c))/(2*a);` Just like the math-notation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.