Program your own calculator

hey guys ,can you help me why am getting wrong answer.

#include<iostream>
#include<cstdio>
#include <iomanip> 

using namespace std;

int main()
{
int A,B;
char C;
cin>>A>>B>>C;

switch(C)
{

case '+':  
      cout<<A+B<<"\n";
	break;
case '-':
	cout<<A-B<<"\n";
	break;
case '/':
	cout<<setprecision(2)<<A/(float)B<<"\n";
	break;
	
case '*':
	cout<<A*B<<"\n";
	
}

return 0;
}

thank you

where did your code fail? be specific.

I got correct answer after setting the prescicsion but i want to know how i should know to use precision because its not mentioned in question also.

Try to read this : https://www.geeksforgeeks.org/difference-float-double-c-cpp/

And see for division case, using “double” rather than “float” works?