Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

In odd/even question if we provide very large value (like up to 12 digits ) then there are error in program;

In odd/even question if we provide very large value (like up to 12 digits ) then there are error in program;

#include<iostream>
using namespace std;

int main(){
    cout<<"This program is for finding if the provided integer is even or odd.\nPls provide the integer...\n";
    int a;
    cin>>a;
    if(a%2==0){
        cout<<"The provided integer is even.";
    }
    else{
        cout<<"The provided integer is odd.";
    }

    return 0;
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Hi the maximum value int can take in C++ is 2,147,483,647 , So 12 digits can’t be handled by int , Use long int insted

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading