Help me to solve the error

Problem : URCALC

I write code for division using both cout and printf

my code(wrong answer) :
#include
using namespace std;

int main() {
	// your code goes here
	double a,b;char c;
	cin>>a>>b>>c;
	switch(c)
	{
	  case '+':
	    cout<<a+b;
	    break;
	  case '-':
	    cout<<a-b;
	    break;
	  case '*':
	    cout<<a*b;
	    break;
	  case '/':
	    cout<<a/b;
	    break;
	}
	return 0;
}

code2 (AC):
#include
using namespace std;

int main() {
	// your code goes here
	double a,b;char c;
	cin>>a>>b>>c;
	switch(c)
	{
	  case '+':
	    cout<<a+b;
	    break;
	  case '-':
	    cout<<a-b;
	    break;
	  case '*':
	    cout<<a*b;
	    break;
	  case '/':
	    printf("%f",a/b);
	    break;
	}
	return 0;
}

can someone help me by pointing out were my first solution goes wrong.

Compare the output of the test input:

8
3
/

with the correct answer, using both of your solutions.

1 Like

Thanks a lot!

1 Like