basics of c porgramming
DESCRIPTION
Basics of C porgrammingTRANSCRIPT
![Page 1: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/1.jpg)
![Page 2: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/2.jpg)
Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
![Page 4: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/4.jpg)
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.
![Page 5: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/5.jpg)
TokensTokens 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
![Page 6: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/6.jpg)
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
![Page 7: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/7.jpg)
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
![Page 8: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/8.jpg)
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.
![Page 9: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/9.jpg)
Header file
Key word
IIdentifiers
Operators
Special symbol
Strings
Header file contains different predefined functions, which are required to run the program
![Page 10: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/10.jpg)
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
Assert.h Ctype.h Math.h
Process.h Stdio.h Stdlib.h
String.h Time.h Graphics.h
Followings are the some commonly used header files which plays a vital role in C programming :
![Page 11: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/11.jpg)
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
![Page 12: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/12.jpg)
Data Types in C :
![Page 13: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/13.jpg)
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
![Page 14: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/14.jpg)
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; }
![Page 15: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/15.jpg)
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;
}
![Page 16: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/16.jpg)
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
![Page 17: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/17.jpg)
While loopIt is used to repeat a block of statements until
condition is true.
Syntax: while(condition) { statements; increment/decrement; }
![Page 18: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/18.jpg)
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.
Syntax: for(initialisation; test-condition; incre/decre)
{statements;
}
#include <stdio.h> #include <conio.h> void main() { int a; for(i=0; i<=5; i++) { printf("\n"); }
![Page 19: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/19.jpg)
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
![Page 20: Basics of C porgramming](https://reader036.vdocuments.site/reader036/viewer/2022062708/558c0751d8b42a663a8b45cd/html5/thumbnails/20.jpg)
Contact Us