2. Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
3. Basic of C
Atheendrh Kakkoth
atheendrh@gmail.com
Atheendrh kakkoth
4. Execution of C Program
•Creating a program :
An editor like notepad or word pad is used to create a C program. This file contains a
source code which consists of executable code. save as .c
• Compiling the program :
The next step is to compile the program. The code is compiled by using compiler. Compiler
converts executable code to binary code
•Linking a program to library :
The object code of a program is linked with libraries that are needed for execution of a
program. The linker is used to link the program with libraries.
•Execution of program :
The final executable file is then run by dos command prompt or by any other software.
5. Tokens
Tokens are individual words marks in passage of text. In C, program
the smallest individual units are known as C Tokens. C has Six
types of Tokens. The Tokens are shown in figure
6. Tokens
• Keywords
– These are reserved words of the C language. For
example int, float, if, else, for,
while etc.
• Identifiers
– An Identifier is a sequence of letters and digits, but
must start with a letter. Underscore ( _ ) is treated as a
letter. Identifiers are used to name variables, functions
etc.
– Valid: Root, _getchar, __sin, x1, x2,
x3, x_1, If
– Invalid: 324, short, price$, My Name
7. Tokens
• Constants
– Constants like 13, ‘a’, 1.3e-5 etc.
• Strings
– A sequence of characters enclosed in double
quotes as “…”. For example “13” is a string literal
and not number 13. ‘a’ and “a” are different.
• Operators
– Arithmetic operators like +, -, *, / ,% etc.
– Logical operators like ||, &&, ! etc. and so on
8. Tokens
• special symbol: ~ ! @ # $ % ^ & * ( ) _ + { } [ ]
-<>,./?|:;"'
• White Spaces
– Spaces, new lines, tabs, comments ( A sequence
of characters enclosed in /* and */ ) etc. These are
used to separate the adjacent identifiers, kewords
and constants.
9. Header file I
Identifiers
Key word
Strings
Special symbol
Operators
Header file contains different predefined functions, which are required to run the
program
10. Header File in C :
Header file contains different predefined
functions, which are required to run the
program. All header files should be included
explicitly before main ( ) function
Followings are the some commonly used header files which plays
a vital role in C programming :
Assert.h Ctype.h Math.h
Process.h Stdio.h Stdlib.h
String.h Time.h Graphics.h
11. Stdio.h
stdio.h refers to standard input/output header file.
The functions which are declared in stdio.h are very
popular.
scanf() -used to take input from the standard input
stream
Printf() -prints to the standard output stream
13. Decision Making Statements
C program executes program sequentially.
Sometimes, a program requires checking of
certain conditions in program execution. These
statements are called as 'Decision Making
Statements' or 'Conditional Statements‘
• Followings are the different conditional
statements used in C.
• If Statement
• If-Else Statement
14. If Statement :
This is a conditional statement used in C to
check condition or to control the flow of
execution of statements.
Syntax:
if(condition)
{
statements;
}
15. If-Else Statement :
This is also one of the most useful conditional
statement used in C to check conditions
Syntax:
if(condition)
{
true statements;
}
else
{
false statements;
}
16. Looping Statements
A loop is used using condition. The repetition is
done until condition is true
• Some common examples of this looping
statements are :
• while loop
• for loop
17. While loop
It is used to repeat a block of statements until
condition is true.
Syntax:
while(condition)
{
statements;
increment/decrement;
}
18. For loop
One of the most important feature of this loop is
that the three actions can be taken at a time like
variable initilisation, condition checking
and increment/decrement. #include <stdio.h>
#include <conio.h>
void main()
Syntax: {
int a;
for(initialisation; test-condition; incre/decre) for(i=0; i<=5; i++)
{
{ printf("n");
statements; }
}
19. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com