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.