statement: write a code in which user first select what type calculator they want to use. Simple or scientific and on that basis they do the calculations.
I have written the following code but it is not running. I am unable to figure out the problem. Please anybody help!!

#include <iostream>
#include <string.h>
#include <conio.h>
#include <math.h>
using namespace std;
int main()
{
int input;
cout << "CHOOSE BETWEEN SCIENTIFIC AND SIMPLE CALCULATOR:" << endl;
cout << "[1] Scientific" << endl << "[2] Simple" <<endl;
cin >> input;

switch(input) 
case '1':
float a,b;
int z;
void Power(float,float);
void Sine(float);
void Square(float);
void Cos(float);
void Tan(float);
void Log(float);
void Baselog(float);
cout<<"WHAT YOU WANT TO FIND: "<<endl;
cout<<"Press '1' for Power: "<<endl;
cout<<"Press '2' for Sin: "<<endl; 
cout<<"Press '3' for Square: "<<endl; 
cout<<"Press '4' for Cos: "<<endl; 
cout<<"Press '5' for Tan: "<<endl;
cout<<"Press '6' for Log: "<<endl;
cout<<"Press '7' for Base Log: "<<endl;

cin>>z;
switch(z)
{
case 1:
cout<<"Enter the Number for Calculating its Power: "<<endl;
int a;
cin>>a;
cout<<"Enter the Power for a Number: "<<endl;
int b;
cin>>b;
Power(a,b);
break;

case 2:
cout<<"Enter the Number for Calculating SIN: "<<endl;
cin>>a;
Sine(a);
break;

case 3:
cout<<"Enter the Number for Calculating Square: "<<endl;
cin>>a;
Square(a);
break;

case 4:
cout<<"Enter the Number for Calculating COS: "<<endl;
cin>>a;
Cos(a);
break;

case 5:
cout<<"Enter the Number for Calculating TAN: "<<endl;
cin>>a;
Tan(a);
break;

case 6:
cout<<"Enter the Number for Calculating LOG: "<<endl;
cin>>a;
Log(a);
break;

case 7:
cout<<"Enter the Number for Calculating LOG WITH BASE 10: "<<endl;
cin>>a;
Baselog(a);
break;
}
getch();
}

void Power(float x,float y)
{
float p;
p = pow(x,y);
cout<<"Power: "<<p;
}

void Sine(float x)
{
float s;
s = sin(x);
cout<<"Sin: "<<s;
}

void Square(float x)
{
float sq;
sq = sqrt(x);
cout<<"Square of a Given Value is: "<<sq;
}

void Cos(float x) 
{
float c;
c = cos(x);
cout<<"COS: "<<c;
}

void Tan(float x)
{
float t;
t = tan(x);
cout<<"TAN: "<<t;
}

void Log(float x)
{
float l;
l = log(x);
cout<<"Natural Logarithm: "<<l;
}

void Baselog(float x);

float bl;
bl = log10(x);
cout<<"LOG with Base 10: "<<bl;

break;

case '2':

int num1,num2;
char op;
cout << "Enter an operator (+, -, *, /): ";
cin >> op; 
cout << "Enter two numbers: " << endl;
cin >> num1 >> num2;

if(op=='+') {
    cout << num1 << " + " << num2 << " = " << num1 + num2; }

else if(op=='-') {
    cout << num1 << " - " << num2 << " = " << num1 - num2; }

else if(op=='*') {
    cout << num1 << " * " << num2 << " = " << num1 * num2; }

else if(op=='/') {
    cout << num1 << " / " << num2 << " = " << num1 / num2; }

else{
        cout << "Error! The operator is not correct"; 
    }            
break;  

return 0;
}

Could you please elaborate on what you mean when you say "it is not running"? Is it failing to compile? Does it compile, but crash? Please give details about the failure mode.

Also, the header <conio.h> isn't valid in any modern compiler, being specific to the now-ancient Turbo C++ compiler suite. If you are still using Turbo C++, STOP. You are doing yourself a disservice by learning an pre-standard version of C++.

Similarly, the C headers <math.h> and <string.h> are renamed <cmath> and <cstring> in modern C++.

commented: I said similar to someone and the reply was "But Turbo C++ is free." +16

Why did you put a semicolon at the end of line 127?
There may be other errors but you should at least correct syntax errors first.

Having taken a closer look at it, I can see that there are serious problems with how the code is edited and structured. Aside from the fact that it is completely un-formatted, I found that a section of code which appears to have been meant to be part of the main() function somehow got misplaced at the end of the code. I have managed to edit the code to at least the point where it compiles; whether it works correctly is up to you to determine.

For the record, I compiled the code in GCC with the shell invocation:

g++ -Wall -Wextra -Werror simple-sci-calc.cpp -o simple-sci-calc

The updated code is:

#include <iostream>
#include <cstring>
#include <cmath>

void Power(float,float);
void Sine(float);
void Square(float);
void Cos(float);
void Tan(float);
void Log(float);
void Baselog(float);

int main()
{
    int input;
    std::cout << "CHOOSE BETWEEN SCIENTIFIC AND SIMPLE CALCULATOR:" << std::endl;
    std::cout << "[1] Scientific" << std::endl << "[2] Simple" <<std::endl;
    std::cin >> input;

    switch(input) 
    {
    case '1':
 //       float a,b;
        int z;

        std::cout<<"WHAT YOU WANT TO FIND: "<<std::endl;
        std::cout<<"Press '1' for Power: "<<std::endl;
        std::cout<<"Press '2' for Sin: "<<std::endl; 
        std::cout<<"Press '3' for Square: "<<std::endl; 
        std::cout<<"Press '4' for Cos: "<<std::endl; 
        std::cout<<"Press '5' for Tan: "<<std::endl;
        std::cout<<"Press '6' for Log: "<<std::endl;
        std::cout<<"Press '7' for Base Log: "<<std::endl;

        std::cin>>z;
        switch(z)
        {
        case 1:
            std::cout<<"Enter the Number for Calculating its Power: "<<std::endl;
            int a;
            std::cin>>a;
            std::cout<<"Enter the Power for a Number: "<<std::endl;
            int b;
            std::cin>>b;
            Power(a,b);
            break;

        case 2:
            std::cout<<"Enter the Number for Calculating SIN: "<<std::endl;
            std::cin>>a;
            Sine(a);
            break;

        case 3:
            std::cout<<"Enter the Number for Calculating Square: "<<std::endl;
            std::cin>>a;
            Square(a);
            break;

        case 4:
            std::cout<<"Enter the Number for Calculating COS: "<<std::endl;
            std::cin>>a;
            Cos(a);
            break;

        case 5:
            std::cout<<"Enter the Number for Calculating TAN: "<<std::endl;
            std::cin>>a;
            Tan(a);
            break;

        case 6:
            std::cout<<"Enter the Number for Calculating LOG: "<<std::endl;
            std::cin>>a;
            Log(a);
            break;

        case 7:
            std::cout<<"Enter the Number for Calculating LOG WITH BASE 10: "<<std::endl;
            std::cin>>a;
            Baselog(a);
            break;
        }

        break;

    case '2':

        int num1,num2;
        char op;
        std::cout << "Enter an operator (+, -, *, /): ";
        std::cin >> op; 
        std::cout << "Enter two numbers: " << std::endl;
        std::cin >> num1 >> num2;

        if(op=='+') {
            std::cout << num1 << " + " << num2 << " = " << num1 + num2; }

        else if(op=='-') {
            std::cout << num1 << " - " << num2 << " = " << num1 - num2; }

        else if(op=='*') {
            std::cout << num1 << " * " << num2 << " = " << num1 * num2; }

        else if(op=='/') {
            std::cout << num1 << " / " << num2 << " = " << num1 / num2; }

        else{
            std::cout << "Error! The operator is not correct"; 
        }            
        break;  
    }
    return 0;
}

void Power(float x,float y)
{
    float p;
    p = pow(x,y);
    std::cout<<"Power: "<<p;
}

void Sine(float x)
{
    float s;
    s = sin(x);
    std::cout<<"Sin: "<<s;
}

void Square(float x)
{
    float sq;
    sq = sqrt(x);
    std::cout<<"Square of a Given Value is: "<<sq;
}

void Cos(float x) 
{
    float c;
    c = cos(x);
    std::cout<<"COS: "<<c;
}

void Tan(float x)
{
    float t;
    t = tan(x);
    std::cout<<"TAN: "<<t;
}

void Log(float x)
{
    float l;
    l = log(x);
    std::cout<<"Natural Logarithm: "<<l;
}

void Baselog(float x)
{
    float bl;
    bl = log10(x);
    std::cout<<"LOG with Base 10: "<<bl;
}
commented: Thanks Sir it helped alot +0
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.