Question

In: Computer Science

Explain simple Vs Structured datatypes in detail. in C++

Explain simple Vs Structured datatypes in
detail. in C++

Solutions

Expert Solution

Simple Datatypes in C++
        Simple data type can only store one value at a time
        1.Integral      
                Integral type can declare - 
                        Integer values, Signed and Unsigned both, 
                                ex. int,signed short int,unsigned short int
                        Boolean values,where true or false can be stored as 1 and 0
                        Characters,which is converted to int by compiler automatically
                                ex.char,signed char,unsigned char
        2.Enum
                Enumerated type is a user-defined datatype which can be assigned some limited
                values.
                These values are defined by the programmer at the time of declaring the enumerated
                type
                For ex. For gender we can use enum as it will only limit user to select from some
                limited options
        3.Floating
                Floating types uses an IEEE-754 representation to provide an approximation
                of fractional values over a wide range of magnitudes
                FOllowing are floating types in c++
                        float 
                                this is the smallest floating pointer in c++
                        double 
                                this is larger than float,but shorter than long double
                        long double
                                is larger than double
        
        EXAMPLE IN C++
                int myNum = 5;               // Integer (whole number)
                float myFloatNum = 5.99;     // Floating point number
                double myDoubleNum = 9.98;   // Floating point number
                char myLetter = 'D';         // Character
                bool myBoolean = true;       // Boolean
        OUTPUT
                int: 5
                float: 5.99
                double: 9.98
                char: D
                bool: 1

Sructered Datatypes in C++
        Structured data can store each dataitem as a collection of other data items
        in structured data rype,the entire collection uses a single identifier name
        The purpose of structured datat types is to group related data of various types for 
        convinient access using same identifier
        
        1.Array
                Array is a collection of fixed number of components of same type
                One dimensional array is array in which components are arranged in list form
                Two dimensional array is array in which components are arranged in tabular form
                Example :
                        int num[5]
                        char str[10]
                        int twoDarray[10][10]
        2.struct
                A struct is a structure user defined data type in c++
                A structure creates a data type that can be used to group items possibly
                different types into a single type
                Example :
                        struct Point 
                        { 
                                int x, y; 
                        } p1;
        3.class
                class is the building block of c++ which leads it to object oriented
                programming
                It is a user-defined data type,which holds its own data members and members
                functions,which can be accessed and used by creating an instance of that clss
                Example :
                        class Student{
                                int studentId = 1;
                                int getStudentId()
                                {
                                        return studentId;
                                }
                        }

Related Solutions

There was a demonstration of the falling magnet in a simple copper tube. Explain, in detail,...
There was a demonstration of the falling magnet in a simple copper tube. Explain, in detail, the physics behind why the magnet slows its descent through the tube (it does not touch the sides). In your discussion be sure to explain why the magnet doesn't come to a stop in the tube and why it does not speed up.
In detail explain: -Ferrous vs Ferric in the blood definition, it's conversion, and where it is...
In detail explain: -Ferrous vs Ferric in the blood definition, it's conversion, and where it is converted (include the whole process) The difference between transferrin, ferritin, and hemosiderin. And the process of how they work together for "recycling and elimination of erythrocyte components".
Explain (in detail) Nuclear Fission and Nuclear Fusion, why is one radioactive vs the other?What is...
Explain (in detail) Nuclear Fission and Nuclear Fusion, why is one radioactive vs the other?What is the nuclear process in a reactor (Fission, or fusion), and what kind of decays is it going through (alpha, beta, or gamma)?What is Critical Mass in nuclear physics?
Explain in detail why stages 5 and 6 of Erikson’s (Identity vs Role Confusion and Intimacy...
Explain in detail why stages 5 and 6 of Erikson’s (Identity vs Role Confusion and Intimacy vs Isolation ) eight stages of personality development may be the highest hurdles to jump in life. Think about your junior high and high school years and what’s to come in your post-high school years. Include physical, emotional, and cognitive aspects and explain how these all fit into Erikson’s stages 5 and 6.
Structured Product Explanation Find a derivative or structured product from any issuer and explain it in...
Structured Product Explanation Find a derivative or structured product from any issuer and explain it in plain English. Having done so, state the problems you may have encountered in conveying the features to a client. The successful submission will clearly and concisely explain the product in a manner appropriate for a retail client who is intelligent but not experienced with investments.
This is C++. It's based on structured data, chapter 11 of Starting out with C++. Please...
This is C++. It's based on structured data, chapter 11 of Starting out with C++. Please use basic operations. Please read the requirements carefully and make sure it's executable. The first 2 answers that I received are nowhere close. Thank you. Secret Codes! Create a program that will accept a message from the user and either encrypt ordecrypt it with the following algorithms: To encrypt: get the character you wish to encrypt find the index of that character in the...
write a simple program to explain vector type in c++... use comments to explain plz
write a simple program to explain vector type in c++... use comments to explain plz
Explain why the equation for PV of a perpetuity is so simple as = C/Rate, if...
Explain why the equation for PV of a perpetuity is so simple as = C/Rate, if is a constant stream of CF that lasts forever?
Explain structured leisure activities and unstructured leisure activities
Explain structured leisure activities and unstructured leisure activities
A tree can be considered as a structured graph. Write a C++ function that receives a...
A tree can be considered as a structured graph. Write a C++ function that receives a BST object and returns its corresponding graph representation, implemented via an adjacency list. What will be the impact on the search complexity?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT