Click here to Skip to main content
15,895,827 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
C++
int main ()
	case 4:
	{
			
			bool c=a.check();
			if (c==true)
			{cout <<"the number is even "<<endl;}
			else
			{cout <<"the number is odd "<<endl;}
		break;
		}

function which I call it :
C#
bool check ( )
{
    cout << "Enter big integer number :";
        string s;
        getline(cin,s);
    string::const_reverse_iterator s1 = s.rbegin();
    if (*s1 %2==0)
    {return true;}
    else
    {return false;}
}
Posted
Updated 12-Dec-14 6:56am
v2
Comments
ZurdoDev 12-Dec-14 12:53pm    
What's the problem?
Member 11303951 12-Dec-14 13:30pm    
the run of this code is not complete
ZurdoDev 12-Dec-14 13:54pm    
So, why can't you complete it?
Member 11303951 12-Dec-14 14:16pm    
i cant define where the Error
ZurdoDev 12-Dec-14 14:19pm    
I don't know what that means.

What is the error and what line of code causes it?

1 solution

The code is actually right, but only on well-behaved input data.
If the user, for instance inputs 'aaaaaaaaaaaaaaaaaaaaabbbbbbbbbb' then the programs recognizes it as 'even'.
 
Share this answer
 
Comments
Andreas Gieriet 12-Dec-14 18:04pm    
My 5. So, the third option is not programmed: ... "is not a number".
Cheers
Andi
Maciej Los 12-Dec-14 18:07pm    
Agree!
Member 11303951 13-Dec-14 15:56pm    
this program for numbers

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900