Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help: insert statements to add 1 to the unsigned and signed maximum number

ID: 3872628 • Letter: N

Question

Need help: insert statements to add 1 to the unsigned and signed maximum number stored in the variable after you calculate the answer, and print the result of increasing the variable by one. Do the same for the unsigned and signed minimum number calculated by subtracting one from the variable and printing the value afterward

current code that i have:

#include<iostream>

#include<climits>

#include<cmath>

using namespace std;

int main()

{

    cout << "Signed Short Minimum :" << SHRT_MIN << endl;

    cout << "Signed Short Maximum : " << SHRT_MAX << endl;

    cout << "Unsigned Short Maximum : " << USHRT_MAX << endl;

    cout << "Signed Int Minimum : " << INT_MIN << endl;

    cout << "Signed Int Maximum : " << INT_MAX << endl;

    cout << "Unsigned Int Maximum : " << UINT_MAX << endl;

    cout << "Signed Long Minimum : " << LONG_MIN << endl;

    cout << "Signed Long Maximum : " << LONG_MAX << endl;

    cout << "Unsigned Long Maximum : " << ULONG_MAX << endl;

   

    cout<<" Enter the number of bits ";

    int n;

    cin>>n;

   

    cout<<" Minimum value of "<<n<<" bit signed number : "<<-(int)pow(2, n - 1)<<endl;

    cout<<"Maximum value of "<<n<<" bit signed number : "<<((int)pow(2, n - 1) - 1)<<endl;

    cout<<"Minimum value of "<<n<<" bit unsigned number : 0 ";

    cout<<"Maximum value of "<<n<<" bit unsigned number : "<<((int)pow(2, n) - 1);

   

    return 0;

}

Explanation / Answer

#include<iostream>
#include<climits>
#include<cmath>
using namespace std;
int main()
{
cout << "Signed Short Minimum :" << SHRT_MIN << endl;
cout<< "Subtracting 1 from Signed Short Minimum : " << SHRT_MIN -1 <<endl;
cout << "Signed Short Maximum : " << SHRT_MAX << endl;
cout<<"Adding 1 to Signed Short Maximum : " << SHRT_MAX +1 <<endl;
cout << "Unsigned Short Maximum : " << USHRT_MAX << endl;
cout<<"Adding 1 to Short Maximum : " << USHRT_MAX +1 <<endl;
cout << "Signed Int Minimum : " << INT_MIN << endl;
cout<<"Subtracting 1 from Signed Int Minimum : " << INT_MIN -1 <<endl;
cout << "Signed Int Maximum : " << INT_MAX << endl;
cout<<"Adding 1 to Signed Int Maximum : " << INT_MAX +1 <<endl;
cout << "Unsigned Int Maximum : " << UINT_MAX << endl;
cout<<"Adding 1 to Unsigned Int Maximum : " << UINT_MAX +1 <<endl;
cout << "Signed Long Minimum : " << LONG_MIN << endl;
cout<<"Subtracting 1 from Signed LONG Minimum : " << LONG_MIN -1 <<endl;
cout << "Signed Long Maximum : " << LONG_MAX << endl;
cout<<"Adding 1 to Signed Long Maximum : " << LONG_MAX +1 <<endl;
cout << "Unsigned Long Maximum : " << ULONG_MAX << endl;
cout<<"Adding 1 to Unsigned Long Maximum : " << ULONG_MAX +1;

cout<<" Enter the number of bits ";
int n;
cin>>n;

cout<<" Minimum value of "<<n<<" bit signed number : "<<-(int)pow(2, n - 1)<<endl;
cout<<"Maximum value of "<<n<<" bit signed number : "<<((int)pow(2, n - 1) - 1)<<endl;
cout<<"Minimum value of "<<n<<" bit unsigned number : 0 ";
cout<<"Maximum value of "<<n<<" bit unsigned number : "<<((int)pow(2, n) - 1);

return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote