465 - Overflow

#include<bits/stdc++.h>
#define Max 2147483647
using namespace std;

int main()
{
    char s[1000],s1[1000];
    char ch;
    double a,b,result;
    while(cin>>s>>ch>>s1)
    {
        a=atof(s);
        b=atof(s1);

        cout<<s<<" "<<ch<<" "<<s1<<endl;

        if(a>Max)
        {
            printf("first number too big\n");
        }
        if(b>Max)
        {
            printf("second number too big\n");
        }

        if(ch=='+')
        {
            result=a+b;
        }
        else if(ch=='*')
        {
            result=a*b;
        }
        if(result>Max)
        {
            printf("result too big\n");
        }

    }
    return 0;
}

0 comments: (+add yours?)