WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

C · Basic · question 3 of 100

What are the different data types in C?

📕 Buy this interview preparation book: 100 C questions & answers — PDF + EPUB for $5

In C programming language, there are several data types that are used to represent different types of data. Here are the different data types in C:

Basic data types: C has several basic data types, which include:

Enumerated data types: Enumerated data types are used to represent a set of named values. The enum keyword is used to define an enumerated data type.

    enum weekDays {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};

In this example, an enumerated data type weekDays is defined with seven named values, representing each day of the week.

Derived data types: Derived data types are created by combining basic data types or other derived data types. Some of the derived data types in C include:

    typedef struct {
        char name[20];
        int age;
    } Person;

In this example, a new data type Person is defined using the typedef keyword. This data type contains two variables, name and age, of type char and int respectively.

Bitwise data types: Bitwise data types are used to work with individual bits of data. C provides several bitwise operators, such as &, |, and ,̂ to manipulate these data types. Some of the bitwise data types in C include:

    unsigned char bitmask = 0b00001111;
    unsigned char data = 0b11010110;
    
    unsigned char result = data & bitmask;

In this example, a bitmask is defined using binary notation, and a data value is defined. The bitwise & operator is used to apply the bitmask to the data value, resulting in a new value where only the first 4 bits are preserved.

Understanding the different data types in C is essential for writing efficient and error-free code. Choosing the right data type for a given variable or function can help optimize performance and prevent unexpected behavior.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic C interview — then scores it.
📞 Practice C — free 15 min
📕 Buy this interview preparation book: 100 C questions & answers — PDF + EPUB for $5

All 100 C questions · All topics