C - Primitive Data types


Learn C - C tutorial - Primitive data types - C examples - C programs

C - Primitive Data types - Definition and Usage

  • The primitive data types in c language are the inbuilt data types provided by the c language itself .
  • Thus, all C compilers provide support for these data types. The Primitive Datatypes are as follows:
    • Integer Data Type (int)
    • Float data Type (float)
    • Double Data Type (double)
    • Character Data Type (char)
    • Void Data Type (void)
C Primitive Data Types

C Primitive Data Types

Integer Data Type (int) :

  • Integer data type allows a variable to store numeric values (7,34,678,32…).
  • int” keyword is used to refer integer data type.
  • The storage size of int data type is 2 or 4 or 8 bytes.

C Syntax

int variable_name;

Float data Type (float) :

  • Float data type declares a variable that can store numbers containing a decimal number (0.7 , 0.46, etc.) .
  • “float” keyword is used to refer float data type.

C Syntax

float variable_name;

Character Data Type (char) :

  • Character variables declared as char data type can only store one single character.
  • “char” keyword is used to refer character data type.

C Syntax

char variable_name;

Void Data Type (void) :

  • Void is an empty data type that has no value. Thus, we can say that it stores null.
  • This can be used in functions and pointers.

C Syntax

void variable_name;

Sample - C Code

#include <stdio.h>
void main()
    int a = 5;
    float b = 5.0;
    char c = 'w';
    long d = 12345;

C Code - Explanation :

  1. Here in the c programming, void main() is declared as a parent function of all the functions in C. If we don't need any return value, we use return type 'void'.
  2. In C programming, int a = 5 is specified as positive integer data type.
  3. In C programming, float b = 5.0 is specified as positive float data type.
  4. In C programming, char c = 'w' is specified as char data type.
  5. In C programming, long d = 12345 is specified as long positive integer data type.
  6. Here, printf() function is used to print the “integer, float, character, double values” onto the output screen where its format specifier is used to display the value of the variables.

Sample Output - Programming Examples

  1. Here in this output A=5 specifies the integer data type.
  2. Here in this output B=5.000000 specifies the float data type.
  3. Here in this output C=w specifies the character data type.
  4. Here in this output D=12345 specifies the long character data type.

View More Quick Examples

Related Searches to C Primitive Data Types

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.