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

Please help with writing the code for the following. Please use plenty of commen

ID: 3873378 • Letter: P

Question

Please help with writing the code for the following. Please use plenty of comments. I don't really understand how to deal with signed vs. unsigned, so please make it really clear what's going on in the program with relation to that. The language is C++, and I'm using vim to write the program.

(20 pts) Write a C++ program that first prints the maximum and minimum values for the http://www.cplusplus.com/reference/climits. Notice there is not a minimum unsigned! You should just enter the numerical literal for this information, and make sure you print proper messages for each min and max you are printing. (62 pts) Now, write a program to calculate and print the maximum and minimum signed and maximum and minimum (which of course is a literal number, that you still need to assign!) unsigned number stored in n bytes, and store the result in a variable to print. You do not have to handle the user entering a number of bytes greater than 8. Think about the equation from class and recitation to determine how many numbers can be represented in 8 bits with two possible choices for each bit. How are you going to express an exponent? In C++, you need to use a built-in function, pow(base, exp), from the cmath library. For example: #include #include using namespace stdi int main) int num - pow (2, 3) cout

Explanation / Answer

#include<iostream>
#include<climits>
using namespace std;
int main()
{
   int n=10;//variable to store the numerical literals...
  
   while(n!=0)//loop runs upto zero is entered...
   {
  
   //showing message
   cout<<"1:Maxvalue for Unsigned int 2:Maxvalue for Unsigned long 3:Maxvalue for Unsigned short ";
   cout<<"4:Maxvalue and Minvalue for signed int ";
   cout<<"5:Maxvalue and Minvalue for signed short ";
   cout<<"6:Maxvalue and Minvalue for signed long ";
   cout<<"0:To exit";
   cout<<"Enter your choice :";
   cin>>n;//reading integer
  
   //unsigned int
   if(n==1)//1 entered
   cout<<"Maximum value for Unsigned int : "<<UINT_MAX<<endl;//UINT_MAX has the maximum value for unsigned int..
   //unsigned long
   else if(n==2)//2 entered
   cout<<"Maximum value for Unsigned long : "<<ULONG_MAX<<endl;//ULONG_MAX has the maximum value for unsigned long..
   else if(n==3)//3 entered
   cout<<"Maximum value for Unsigned short : "<<USHRT_MAX<<endl;//USHRT_MAX has the maximum value for unsigned short..
   else if(n==4)//4 entered  
   cout<<"Maximum value for signed int : "<<INT_MAX<<" Minimum value for signed int :"<<INT_MIN<<endl;//INT_MAX has the maximum value for signed int,INT_MIN has the minimum value for singed int..
   else if(n==5)//5 entered
   cout<<"Maximum value for signed lont : "<<LONG_MAX<<" Minimum value for signed long :"<<LONG_MIN<<endl;//LONG_MAX has the maximum value for signed long,LONG_MIN has the minimum value for singed long..
   else if(n==6)//6 entered
   cout<<"Maximum value for signed short : "<<SHRT_MAX<<" Minimum value for signed short :"<<SHRT_MIN<<endl;//INT_MAX has the maximum value for signed short,INT_MIN has the minimum value for singed short..
   else if(n==0)//0 entered
   break;
   else
   cout<<"Enter valid literal ";
   }
   return 0;
}

OUTPUT:

1:Maxvalue for Unsigned int
2:Maxvalue for Unsigned long
3:Maxvalue for Unsigned short
4:Maxvalue and Minvalue for signed int
5:Maxvalue and Minvalue for signed short
6:Maxvalue and Minvalue for signed long
0:To exitEnter your choice :1
Maximum value for Unsigned int : 4294967295
1:Maxvalue for Unsigned int
2:Maxvalue for Unsigned long
3:Maxvalue for Unsigned short
4:Maxvalue and Minvalue for signed int
5:Maxvalue and Minvalue for signed short
6:Maxvalue and Minvalue for signed long
0:To exitEnter your choice :2
Maximum value for Unsigned long : 4294967295
1:Maxvalue for Unsigned int
2:Maxvalue for Unsigned long
3:Maxvalue for Unsigned short
4:Maxvalue and Minvalue for signed int
5:Maxvalue and Minvalue for signed short
6:Maxvalue and Minvalue for signed long
0:To exitEnter your choice :3
Maximum value for Unsigned short : 65535
1:Maxvalue for Unsigned int
2:Maxvalue for Unsigned long
3:Maxvalue for Unsigned short
4:Maxvalue and Minvalue for signed int
5:Maxvalue and Minvalue for signed short
6:Maxvalue and Minvalue for signed long
0:To exitEnter your choice :4
Maximum value for signed int : 2147483647
Minimum value for signed int :-2147483648
1:Maxvalue for Unsigned int
2:Maxvalue for Unsigned long
3:Maxvalue for Unsigned short
4:Maxvalue and Minvalue for signed int
5:Maxvalue and Minvalue for signed short
6:Maxvalue and Minvalue for signed long
0:To exitEnter your choice :5
Maximum value for signed lont : 2147483647
Minimum value for signed long :-2147483648
1:Maxvalue for Unsigned int
2:Maxvalue for Unsigned long
3:Maxvalue for Unsigned short
4:Maxvalue and Minvalue for signed int
5:Maxvalue and Minvalue for signed short
6:Maxvalue and Minvalue for signed long
0:To exitEnter your choice :6
Maximum value for signed short : 32767
Minimum value for signed short :-32768
1:Maxvalue for Unsigned int
2:Maxvalue for Unsigned long
3:Maxvalue for Unsigned short
4:Maxvalue and Minvalue for signed int
5:Maxvalue and Minvalue for signed short
6:Maxvalue and Minvalue for signed long
0:To exitEnter your choice :0


Process exited normally.
Press any key to continue . . .