w1coding.comAll tutorials

C Variables

C lessons
  1. Environment Setup
  2. Introduction
  3. Variables
  4. Operators
  5. Condition
  6. Loops
  7. Functions
  8. Arrays
  9. Pointers
  10. Strings
  11. Struct
  12. File
  13. Memory
  14. Recursions
  15. Bitwise
  16. Directives
  17. Commandline
  18. Switch
  19. Enum
  20. Structp
  21. Arraysofstr
  22. Macros
  23. Pointer Arrays
  24. Linked
  25. Stack
  26. Queue
  27. Graph

C Variables and Data Types

In C, variables are used to store data, and each variable has a type that determines the kind of data it can store.

Common Data Types

  • int - for integers
  • float - for floating-point numbers
  • double - for double precision floating-point numbers
  • char - for single characters

Example of Variables

#include 

int main() {
    int age = 25;
    float height = 5.9;
    char grade = 'A';
    printf("Age: %d\n", age);
    printf("Height: %.1f\n", height);
    printf("Grade: %c\n", grade);
    return 0;
}
    

This program declares variables of type int, float, and char and prints their values.