Fundamental Data Types in C Programming

Basic Data Types

Type Descriptino Memory Size (Bytes)
char Character data 1
short Short integer 2
int Integer 4
long Long integer 4
long long Extended integer 8
float Single-precision floating point 4
double Double-precision floating point 8

Variables

Variables can be classified as local or global, representing values that change during program execution.

#include <stdio.h>

int global_value = 10;   // Global variable

int main() {
    int local_value = 50;  // Local variable
    printf("%d\n", global_value);
    printf("%d\n", local_value);
    
    return 0;
}

Local variables exist only within their defined scope (within the same {} block), created when the local code executes and destroyed when it completes.

Global variables are defined outside any function and are accessible throughout the entire program, created when the program starts and destroyed when it terminates.

Constants

C supports several constant types:

  • Literal constants
  • Const-qualified variables
  • #define symbolic constants
  • Enumeration constants
#include <stdio.h>

#define LIMIT 200   // Symbolic constant

int main() {
    // Literal constants
    42;
    2.718;
    'z'; // Character in single quotes
    "hello";  // String literal

    // Const-qualified variable
    const int value = 25;  // Has constant properties but is technically a variable
    // value = 35;   // Error: const variable cannot be modified

    // Enumeration constants
    enum Status {
        ACTIVE,
        INACTIVE,
        PENDING
    };

    enum Status current = ACTIVE;
    
    return 0;
}

Strings

int main() {
    char text[] = "example";   // String stored as character array, null-terminated
    char buffer[20] = "text";  // Character array with fixed size
    
    return 0;
}

Escape Sequences

Escape Sequecne Description
\? Prevents interpretation as trigraph
\' Represents single quote character
\" Represents double quote within string
\\ Represents backslash character
\a Alert (bell) character
\b Backspace
\f Form feed
\n Newline
\r Carriage return
\t Horizontal tab
\v Vertical tab
\ddd Octal number (1-3 digits)
\xdd Hexadecimal number (2 digits)

Tags: c programming Data Types Variables constants strings

Posted on Mon, 10 Aug 2026 16:19:45 +0000 by mgallforever