0% found this document useful (0 votes)
10 views6 pages

Programming in C: Introduction To C Language

The document provides an overview of the C programming language, including its history, classification as a high-level language, and key features such as portability and support for pointers. It also discusses the structure of a C program, constants, variables, identifiers, keywords, and data types. Additionally, it explains the differences between low-level and high-level languages, as well as the roles of language translators like compilers and interpreters.

Uploaded by

Dousik Manokaran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Programming in C: Introduction To C Language

The document provides an overview of the C programming language, including its history, classification as a high-level language, and key features such as portability and support for pointers. It also discusses the structure of a C program, constants, variables, identifiers, keywords, and data types. Additionally, it explains the differences between low-level and high-level languages, as well as the roles of language translators like compilers and interpreters.

Uploaded by

Dousik Manokaran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Programming in C

Introduction to C Language
 The language of computers is – 0s and 1s.
 Languages can be broadly classified into two categories – Low-
Level languages (such as Machine Language, etc.) and High-Level
languages (such as C, C++, etc.).
 C language was developed by Dennis Ritchie in 1972 at Bell
Laboratories.
 C is a successor of the B language.
 C is the most popular and widely-used programming language.
 After it’s development, it was standardized by ANSI in 1989.
 C is a compiler-based language.
 The C program is written in a .c file. Then, a compiler converts the
high-level code to bunch of zeros and ones (object code), which
the machine can understand.

Low-Level vs. High-Level Languages


Low-Level High-Level

Machine Languages (Purely based on 0s Takes entire source code


and 1s) and converts to machine
 Can be directly executed. code.

Assembly Languages (Allows use of


certain symbols) Either by using a compiler
 Assembler converts the code to or interpreter.
machine language.

Independent of
Dependent on Architecture. Architecture but might be
OS dependent.
Language Translators
 There are three types of language translators:
o Assembler (Converts Assembly Language to Machine Code)
o Compiler (Converts High-Level Language)
o Interpreter (Converts High-Level Language)
 The difference between compiler and interpreter is, compiler
executes the program after complete translation, whereas
interpreter converts and executes parallelly, line-by-line.
 Compiler creates an object code while interpreter directly gives the
output.

Features of C Language
 It’s a High-Level Language.
 It’s a small language with only 32 keywords.
 Most of the languages are dependent on C.
 It’s portable.
 It has a few built-in functions and operators.
 It has access to pointers.
 It’s an extensible, structured and modular language.
 It allows dynamic memory allocation paradigms.
 It’s compilation and execution is faster.
 It’s a case sensitive language.
 It’s used to develop and operate embedded systems. That’s why
it’s also known as system programming language.

Structure of a C Program
1. Documentation Section – Compiler ignores this part. It is solely
done to help the fellow developers out.
a. Single Line Comment - //
b. Multiple Line Comments - /* … */
2. Link Section – Basically importing header files (aka libraries) to use
the functions.
a. #include<stdio.h>
b. #include<conio.h>
c. #include<math.h>
d. #include<string.h>
e. #include<stdlib.h>
3. Definition Section - #define variable_name value
4. Global Declaration Section – Declaring global variables (outside the
functions).
5. Main Section – Code control always goes to the main function first.
(datatype main() { … }).
6. Sub-program functions – User defined functions.

Execution Process of a C Program


Constants in C
 There are two main types of constants in C:
o Numeric Constants
 Integer Constants
 Decimal (Default)
 Octal
 Hexadecimal
 Floating/Real Constants
o Character Constants
 Single Character Constants
 String Constants
 C supports typecasting - ASCII.
 “a” is not same as ‘a’ in C.
 It is generally recommended to capitalize the constants.

Variables in C
 Variables are basically a named memory location which is used to
store a value of a data.
 First step to creating a variable is declaring the datatype of the
variable names.
 Example: char, int, float, double, etc.
 The datatype of a variable cannot be void.
 Variable names cannot have spaces or special characters. It can
also not start with a number or underscore.

Identifiers and Keywords in C


 Reserved, pre-defined words are known as keywords.
 In ASCII C, there are 32 keywords.
 Some examples include, int, float, break, goto, if, for, etc.
 Keywords cannot be used as identifiers.
 Identifiers, as the name suggests, identifies user-defined entities –
variables, functions, etc.
 Some rules to creating identifiers are:
o It can consist of alphabets, numbers and underscore. It
cannot contain any special characters.
o The first character can be alphabets and, in some compilers,
underscore too. But it cannot start with a number.
o It cannot be a keyword.

Datatypes in C
 Datatypes denote the type of data and size of memory to be
allocated.
 There are three types of data types:
o Primary – Built-in/fundamental
 Examples: int, float, char, void, double
o Derived – Derived using primary data types, etc.
 Examples: array, structure, union and pointers
o User-defined – typedef and enumerated.
 int – short int and long int + unsigned int and signed int (4
qualifiers - common).
 The size of the datatype depends upon the compilers in some
cases. To get the size, run: printf(“%d”, sizeof(int)).

You might also like