Facts about C
- C was invented to write an operating system called UNIX.
- C is a successor of B language which was introduced around the early 1970s.
- The language was formalized in 1988 by the American National Standard Institute (ANSI).
- The UNIX OS was totally written in C.
- Today C is the most widely used and popular System Programming Language.
- Most of the state-of-the-art software have been implemented using C.
- Today's most popular Linux OS and RDBMS MySQL have been written in C.
Why use C?
C was initially used for system development work, particularly the programs that make-up the operating system. C was adopted as a system development language because it produces code that runs nearly as fast as the code written in assembly language.
Tokens in C
A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.
Identifiers
A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits (0 to 9).C does not allow punctuation characters such as @, $, and % within identifiers. C is a case-sensitive programming language.
examples:- abc, _xyz, hjTkk, x_89, myname50,etc...
Data Type
Data types define the type of data a variable can hold, for example an integer variable can hold integer data, a character type variable can hold character data etc.
There are two types of data type:-
i) Basic data type:-These are fundamental data types in C namely integer(int), floating point(float), character(char) .
Following are the examples of basic data types used in C:
- char: The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
- int: As the name suggests, an int variable is used to store an integer.
- float: It is used to store decimal numbers (numbers with floating point value) with single precision.
Data types that are derived from fundamental data types are derived types. For example: arrays, pointers, function types, structures, etc.
Basic types
Here's a table containing commonly used types in C programming for quick access.
| Type | Size (bytes) | Format Specifier |
|---|---|---|
int | 2 | %d, %i |
char | 1 | %c |
float | 4 | %f |
- A variable can have alphabets, digits, and underscore.
- A variable name can start with the alphabet, and underscore only. It can't start with a digit.
- No whitespace is allowed within the variable name.
- A variable name must not be any reserved word or keyword, e.g. int, float, etc.
- Auto 12. Break 23. Struct
- For 13. Case 24. Switch
- Goto 14. Char 25. Typeof
- If 15. Const 26. Union
- Int 16. Continue 27. Unsigned
- Long 17. Default 28. Void
- Register 18. Double 29. Volatile
- Return 19. Enum 30. While
- Short 20. Extern 31. Do
- Signed 21. Float 32. Else
- Sizeof 22. Static
Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below −
/* Hello Friends*/
// is also used for single line comments.
0 Comments