• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Data Types in C/C++ Programming

By Abhishek Ghosh May 22, 2024 4:17 pm Updated on May 22, 2024

Data Types in C/C++ Programming

Advertisement

Our previous article on Data Types describes the use of data types in various programming languages. Data types in C are declarations for memory addresses or variables that determine which operators and functions can be applied to the addresses and variables.

C provides basic arithmetic data types for storing integers and floating-point numbers, as well as the syntax needed to create fields and compound types. Several header files in the C standard library also offer definitions of other data types, each of which has certain useful properties. In the C programming language, understanding data types is fundamental for writing efficient and bug-free code. Sometimes, while writing code, a statement may not be illegal to the compiler but in reality, it may not get executed because of error related to data type.

 

Basic Data Types

 

Integer Types

Advertisement

---

Integers represent whole numbers without any fractional part. In C, integers can be classified into several types based on their range and storage size:

  • char: Represents a single byte (typically 8 bits) capable of storing a character or small integer value.
  • short: Typically a 16-bit integer used when memory is a constraint.
  • int: Usually a 32-bit integer on most modern systems. It’s the most commonly used integer type.
  • long: A 32-bit or 64-bit integer, depending on the system architecture.
  • long long: Introduced in the C99 standard, provides at least 64 bits of precision.

Floating-Point Types

Floating-point types are used to represent real numbers with a fractional part. In C, they are typically classified into two types:

  • float: Single-precision floating-point type, occupies 4 bytes and provides about 6 decimal digits of precision.
  • double: Double-precision floating-point type, occupies 8 bytes and offers about 15 decimal digits of precision.

Void Type

The void type specifies that no value is available. It is commonly used to indicate that a function does not return any value or to declare generic pointers.

Data Types in C Programming

 

Derived Data Types

 

Arrays

Arrays are collections of elements of the same data type stored in contiguous memory locations. They provide a convenient way to store and manipulate a fixed-size sequence of elements.

Vim
1
int numbers[5] = {1, 2, 3, 4, 5};

Pointers

Pointers are variables that store memory addresses. They enable dynamic memory allocation and manipulation of data structures like arrays and strings.

Vim
1
2
3
int *ptr;
int num = 10;
ptr = # // ptr now points to the memory address of num

Structures

Structures allow you to group multiple variables of different data types under a single name. They are especially useful for organizing related data.

Vim
1
2
3
4
5
struct Person {
char name[50];
int age;
float height;
};

Union

A union is a special data type that allows storing different data types in the same memory location. Only one member of the union can be accessed at a time.

Vim
1
2
3
4
5
union Data {
int i;
float f;
char str[20];
};

Enumerations

Enumerations (enums) enable you to define a set of named integer constants. They provide a way to create symbolic names for integral values, improving code readability.

Vim
1
2
enum Weekday { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
enum Weekday today = Tuesday;

 

Modifiers

 

C provides various type modifiers to alter the storage size and range of basic data types:

  • signed and unsigned: Modifiers used with integer types to specify whether they can hold negative values or only non-negative values.
  • short and long: Alter the storage size of integer types, where short reduces the size and long increases it.
  • const: Specifies that a variable’s value cannot be changed once initialized.
  • volatile: Indicates that a variable’s value may be changed at any time by external sources, thus preventing compiler optimization.

 

Conclusion

 

Understanding data types is fundamental for writing robust and efficient C programs. By selecting appropriate data types, you can optimize memory usage, improve code readability, and ensure compatibility across different platforms. Mastery of data types empowers programmers to write clearer, more efficient, and maintainable code in the C programming language.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Data Types in C/C++ Programming

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • Changing Data With cURL for OpenStack Swift (HP Cloud CDN)

    Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad.

  • PHP Snippet to Hide AdSense Unit on WordPress 404 Page

    Here is Easy PHP Snippet to Hide AdSense Unit on WordPress 404 Page to Avoid Policy Violation and Decrease False Impression, False Low CTR.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy