C LANGUAGE

C Language – Inventory & Versions

🌟 C Language – Inventory & Versions

This page covers the history, versions, syntax, data types, variables, constants, and operators in C with examples.


1. Inventory (History & Origin)

YearEvent
1969–1972Developed by Dennis Ritchie at Bell Labs as a system programming language for UNIX.
1978K&R C (first edition of The C Programming Language book published).
1989ANSI C (C89) standard approved by ANSI.
1990ISO C (C90) standardized internationally.
1999C99 update introduced inline functions, variable-length arrays, // comments, and more.
2011C11 introduced multi-threading support, Unicode handling, bounds-checking functions.
2018C18 (minor revision of C11) — bug fixes and clarifications.

2. Why Use C?

  • Foundation of programming – base for languages like C++, Java, C#.
  • System-level programming – OS, compilers, embedded systems.
  • Portable – runs on almost any hardware.
  • Performance – faster execution with low-level memory access.

3. Advantages of C

  1. Portable – works on different machines.
  2. Structured – modular programming support.
  3. Rich library – many built-in functions.
  4. Memory control – direct pointer manipulation.
  5. Fast execution – compiled directly to machine code.

4. Versions Summary

VersionYearMain Features
K&R C1978Original syntax & features.
ANSI C (C89)1989Standardized syntax, function prototypes, new keywords.
ISO C (C90)1990International standard with fixes.
C991999Inline functions, variable-length arrays, long long int, // comments.
C112011Multi-threading, Unicode, _Static_assert.
C182018Minor bug fixes and clarifications.
📌 Basic Syntax in C
Syntax is the rule of writing C programs. If you break rules, you get errors.
#include <stdio.h> // Header file
int main() { // main function
printf("Hello, World!");
return 0;
}
Output:
Hello, World!
  • Every statement ends with ;
  • main() is the starting point
  • { } group statements
  • #include adds header files
📌 Output in C

Output is the result displayed after running the program.

#include <stdio.h>
int main() {
printf("I am learning C");
return 0;
}
Output:
I am learning C
📌 Comments in C

Comments are ignored by compiler, used for explaining code.

Types:
  • Single-line: // This is a comment
  • Multi-line: /* This is multi-line */
#include <stdio.h>
int main() {
// Printing a message
printf("Backbenchers learn fast!");
/* This is
multi-line comment */
return 0;
}
Output:
Backbenchers learn fast!
📌 Data Types in C

Data types tell what kind of data a variable can store and memory size.

TypeSize
char1 byte
int4 bytes
float4 bytes
double8 bytes
long long int8 bytes
#include <stdio.h>
int main() {
int age = 20;
char grade = 'A';
float pi = 3.14;
double bigPi = 3.14159265;
printf("Age: %d\\n", age);
printf("Grade: %c\\n", grade);
printf("PI: %.2f\\n", pi);
printf("PI (double): %.8lf", bigPi);
return 0;
}
Output:
Age: 20
Grade: A
PI: 3.14
PI (double): 3.14159265
📌 Keywords in C

Keywords are reserved words that cannot be used as identifiers.

Example: int number = 5; → here int is a keyword.

Some keywords:

auto, break, case, char, const, continue, default, do, else, enum, extern, float, for, goto, if, int, long, return, short

📌 Variables in C

A variable is a named memory location to store data.

Rules:
  • Must start with letter or underscore
  • Case-sensitive
  • No spaces, no keywords
  • Should be meaningful
#include <stdio.h>
int main() {
int age = 20;
float price = 99.50;
char grade = 'A';
printf("Age: %d\\n", age);
printf("Price: %.2f\\n", price);
printf("Grade: %c", grade);
return 0;
}
Output:
Age: 20
Price: 99.50
Grade: A
📌 Constants in C

Constants are fixed values that cannot be changed during execution.

  • Integer constants: 10, -45, 0
  • Floating-point: 3.14, -0.001
  • Character: 'A', 'z'
  • String: "Hello"
#define PI 3.1416
const int age = 18;
📌 Operators in C

Operators perform operations on variables and values.

  • Arithmetic: +, -, *, /, %
  • Relational: ==, !=, >, <, >=, <=
  • Logical: &&, ||, !
  • Assignment: =, +=, -=, *=, /=
  • Increment/Decrement: ++, --
  • Bitwise: &, |, ^, ~, <<, >>
  • Ternary: (condition) ? true : false

Comments

  1. C language,we are learn in easy way to understand and also explanation with examples.

    ReplyDelete

Post a Comment

frequently used resource

Operators and expressions

Looping statements in c