Introduction to C Language-1
Introduction to C Language-1
Language
History of C
Origin: Developed by Dennis Ritchie at Bell laboratories of AT&T (American Telephone &
Telegraph), located in the U.S.A. It was developed to overcome the problems of previous
languages such as B, BCPL, etc.
Purpose: Originally designed for system programming, specifically for creating the UNIX
operating system.
Evolution: Derived from the B language, which itself was influenced by BCPL. C has
influenced many later languages, such as C++, Java, and C#.
Significance: C is known for its efficiency and control, making it a popular choice for system
programming, embedded systems, and applications requiring high performance.
What is B and BCPL
B and BCPL are both early programming languages that have historical significance in the
development of modern programming languages.
B:
Definition: The character set in C includes all the characters that can be used in a C program.
This includes letters (uppercase and lowercase), digits, special characters, and control
characters.(\n (newline), \t (tab), etc.)
Examples:
Structure of the C program
The return value can indicate whether the
program ended successfully or encountered an
error:
// Variable Declarations
// Input/Output Operations
// Logic/Function Calls
return 0; // Return statement
}
User-Defined Function Definitions (if any)
Comments
● A comment is an explanation or description of the source code of the
program.
● It helps a programmer to explain the logic of the code and improves program
readability.
● At run-time, a comment is ignored by the compiler.
Multi-line comment
Represented as /* any_text */ start with forward slash and asterisk (/*) and end with asterisk and forward slash
(*/).
It is used to denote single as well as multi-line comment.
Example: /* multi line comment line -1
Single line comment
Header File
● Begin with #
● Instruct the compilerto perform some transformation to file before compiling
● Example: #include <stdio.h>
○ add the header file stdio.h to this file
○ .h for header file
○ stdio.h defines useful input/output functions
Header files
Main() Method
● The body of a function in the C program refers to statements that are a part of
that function.
● It can be anything like manipulations, searching, sorting, printing, etc. A pair
of curly brackets define the body of a function.
● All functions must start and end with curly brackets.
Statement