Easy and Fundamentals of C Programming: An In-Depth Look at Variables, Data Types, Operators, and More

 C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system.

Here are some basic concepts of C programming:

  1. Variables: A variable is a storage location in memory that holds a value. It has a name, a data type, and a value.

  2. Data types: C supports various data types such as int, float, char, etc.

  3. Operators: C supports various operators such as arithmetic, relational, logical, and bitwise operators.

  4. Control statements: C supports various control statements such as if-else, for, while, and do-while loops.

  5. Functions: C supports the use of functions, which are self-contained blocks of code that can be called by other parts of the program.

  6. Arrays: C supports arrays, which are collections of variables of the same data type.

  7. Pointers: C supports the use of pointers, which are variables that store memory addresses.

  8. Strings: C supports strings, which are arrays of characters terminated by a null character.

  9. File handling: C supports file handling, which allows you to read from or write to a file.

  10. Preprocessor: C has a preprocessor which is a program that processes the source code before the compiler translates it.



Before lean You just Note this below

"Constants in C Programming: Types, Descriptions, and Examples"
CategoryType of ConstantDescriptionExample
Numeric ConstantsInteger ConstantA positive or negative whole number.12, -7
Real ConstantA fractional number, can be represented in different forms: Floating Point Constant and Real Constant in Exponential Form3.14, 6.8e8
Character ConstantsSingle Character ConstantA single character, such as an alphabet, digit, or special symbol enclosed within single quotes.'a', 'Z', '3', '$'
String Character ConstantA sequence of characters enclosed in double quotes."Hello World!", "19282"
Special Characters\'Single quote'''
\"Double quote'"'
\\Backslash'\'
\nNewline'\n'
\tHorizontal tab'\t'
\rCarriage return'\r'
\aAlert or bell'\a'
\bBackspace'\b'
\fForm feed'\f'
\vVertical tab'\v'

Please note that some of these characters have different behavior on different systems, and please keep in mind that these are the standard backslash characters but it may vary based on the operating system or compiler you are using.



In C programming, type qualifiers are used to specify the properties of a variable. Here are some common basic types and their corresponding qualifiers, and their size in bytes:

TypeQualifierSize (bytes)
charsigned/unsigned1
shortsigned/unsigned2
intsigned/unsigned4
longsigned/unsigned4
long longsigned/unsigned8
float-4
double-8
long double-10

It's worth noting that the size of these types may vary depending on the compiler, operating system, and architecture. Also, some compilers support more types like _int8, _int16, _int32, _int64 which are also platform dependent.

Please keep in mind that these are the standard types and their size but it may vary based on the operating system or compiler you are using.


Table: Integer and Variable


CategoryDescriptionExample
IntegerOccupies memory within computer memorysigned integer, unsigned integer
Integer StorageMemory used to store depends on machine configuration16-bit processor: 2 byte integer type can occupy, 32-bit processor: 4 byte of memory of integer value, 64-bit processor: 8 byte of memory of integer value
Type ModifierC language allows alteration of integer storage using type modifiershort int, long int (greater)
ModifiersMemory occupied by different data typeschar (signed/unsigned), 1 byte, short (signed/unsigned), 2 bytes, int (signed/unsigned), 4 bytes, long (signed/unsigned), 4 bytes, long long (signed/unsigned), 8 bytes, float, 4 bytes, double, 8 bytes, long double, 10 bytes
Fractional ValueFractional values cannot be stored in integer type, truncation of fractional valueUse float data type to store integer values
Variable IntroductionNamed location in memory that holds specific data typeExample: Integer variable can only store integer values, cannot store other values such as float and character
Variable DeclarationSyntax: data_type variable_nameExample: int x, y, z (comma separated)
Variable RulesVariable name must begin with a letter or underscore, case sensitive, can be constructed with digits and letters, cannot use special symbols other than underscore, keywords cannot be used, recommended to use 8 characters or less
Variable InitializationSyntax: data_type variable_name = value;Example: int x = 50, y = 30 (x and y are of type integer)
Variable ScopeLocal Variable: declared inside a function, Formal Parameter: variable can be a formal parameter, Global Variable: declared outside a function

Comments