Description
1)
The C library function double atof(const char *str) converts the string argument str to a floating-point number (type double).
2)
printf(" int min : %d ", INT_MIN); // INT_MIN, INT_MAX, SCHAR_MIN, SCHAR_MAX ....etc
printf(" int max : %d ",INT_MAX);// pre defined constants to get the values of datatypes
code:
#include<bits/stdc++.h>
using namespace std;
#include<string.h>
int main()
{
long long l,x,sum,i;
long double aa,bb;
char a[1000],ch,b[1000];
while(cin>>a)
{
cin>>ch>>b;
aa=atof(a);
bb=atof(b);
//cout<<aa<<" "<<bb<<endl;
//cout<<a<<" "<<b<<" "<<INT_MAX<<endl;
cout<<a<<" "<<ch<<" "<<b<<endl;
if(aa>INT_MAX)
cout<<"first number too big\n";
if(bb>INT_MAX)
cout<<"second number too big\n";
if(ch=='+')
{
if(aa+bb>INT_MAX)
cout<<"result too big\n";
}
else if(ch=='*')
{
if(aa*bb>INT_MAX)
cout<<"result too big\n";
}
}
return 0;
}
No comments:
Post a Comment