Problem 5: Write pseudocode of a program that takes a number that represents data_Type, another
variable sign_Unsign to further classify the data type as signed or unsigned, and a number from the user.
Verify if that number can be stored in that given data type. Range of each datatype is given in the table
below.
Input:
1. Take data_Type from the user, if the user enters value other than 1 or 2 ask to input data_Type
again.
2. Take sign_Unsign from the user, if the user enters anyother value than 0 or 1 ask to input
sign_Unsign again
3. Take number (any)
#include<iostream>
using namespace std;
int main()
{
string x,y;
int n;
cout<<"Enter a datatype: ";
cin>>x;
if(x=="1" or x=="2"){
cout<<"Enter the data type";
cin>>x;
}
else{
cout<<"You have entered "<<x;
}
cout<<"\nEnter the value of sign_unsign: ";
cin>>y;
if(y=="0" or y=="1"){
cout<<"\nEnter the value of sign _unsign: ";
cin>>y;
}
else{
cout<<"You have entered "<<y;
}
cout<<"\nEnter a number: ";
cin>>n;
cout<<"The number entered is "<<n;
}
Comments
Leave a comment