Data Types

Programming Fundamentals DSA practice problem on Onlearn.

Difficulty: easy.

Topics: Binary Search Algorithm: Concept, Implementation, and Variations, Data Types, Strings, String Manipulation, Range Checking, complexity analysis, array, divide and conquer, iterative vs recursive, binary search, Binary Search, Algorithmic Paradigms, Sorted & Rotated Arrays, Iterative vs. Recursive Approaches, Time & Space Complexity Analysis.

Data Type Checker Problem Statement You are given a string S representing an integer. Your task is to determine if this integer can be successfully represented by various standard C++ integer data types without overflow. For each specified data type, you must output "Yes" if the integer represented by S falls within its valid range, and "No" otherwise. Input Specification A single line containing a string S which represents an integer. S can be positive, negative, or zero. It may optionally start with a '+' sign for positive numbers, or a ' ' sign for negative numbers. For S = "0", there are no leading zeros. For other values, leading zeros are allowed (e.g., "007", " 010"). Output Specification Output five lines. Each line should contain either "Yes" or "No", corresponding to whether the integer can be represented by the following C++ data types, in this exact order: 1. signed char 2. short int 3. int 4. long int 5. long long int Constraints The length of S will be between 1 and 20, inclusive. S will only contain digits ('0' '9'), and optionally a single leading '+' or ' ' sign. Sample Test Cases Sample Input 1: Sample Output 1: Explanation 1: The input number 1,234,567,890,123,456,789 exceeds the maximum value for signed char, short int, int, and long int. It fits within the range of long long int. Sample Input 2: Sample Output 2: Explanation 2: The input number 123 is small enough to be represented by all standard integer data types listed.