Why are double and void data types but long is not?

Debojit Acharjee 455 Reputation points
2023-06-12T11:29:04.2366667+00:00

In C double is considered a primary data type that can store floating-point numbers, but why double is also taken as a data type if it's the same as float?

Moreover, why long is not considered a data type?

If void means empty then why it's also considered as a data type?

Developer technologies | C++
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2023-06-12T13:41:28.4933333+00:00

    Moreover, why long is not considered a data type?

    long is a type.

    See : Built-in types (C++)

    0 comments No comments

  2. Minxin Yu 13,506 Reputation points Microsoft External Staff
    2023-06-13T02:45:47.0366667+00:00

    Hi,

    Since you're using C not C++, you'd better tell us which compiler you're using.

    I don't see any difference in digits of the output results between double and float.

    Check the sample:

    #include <stdio.h>
    
    
    int main() {
        float floatValue   = 3.1415926535897932384626433832795f;
        double doubleValue = 3.1415926535897932384626433832795;
    
        printf("Float: %.*f\n", 17,  floatValue);
        printf("Double: %.*lf\n", 17, doubleValue);
        return 0;
    }
    
    

    The result :

    enter image description here

    and your example uses 1 instead of the more typical decimal

     float a = 1.1f;
     double b = 1.1;
    

    enter image description here

    For the second question, I don't understand what you are struggling with. Read the usage of void in C: The void type in C.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.