Answer to Question #243947 in C++ for gary

Question #243947

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)


1
Expert's answer
2021-09-29T01:18:45-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS