Successfully reported this slideshow.

Basics of C porgramming


Published on

Basics of C porgramming

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Basics of C porgramming

  1. 1. Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .Ltd
  2. 2. Basic of C Atheendrh Kakkoth Atheendrh kakkoth
  3. 3. Execution of C Program•Creating a program :An editor like notepad or word pad is used to create a C program. This file contains asource 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. Compilerconverts 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 aprogram. 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.
  4. 4. TokensTokens are individual words marks in passage of text. In C, programthe smallest individual units are known as C Tokens. C has Sixtypes of Tokens. The Tokens are shown in figure
  5. 5. 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
  6. 6. 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
  7. 7. 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.
  8. 8. Header file I Identifiers Key word Strings Special symbol OperatorsHeader file contains different predefined functions, which are required to run the program
  9. 9. Header File in C :Header file contains different predefinedfunctions, which are required to run theprogram. All header files should be includedexplicitly before main ( ) functionFollowings are the some commonly used header files which playsa vital role in C programming : Assert.h Ctype.h Math.h Process.h Stdio.h Stdlib.h String.h Time.h Graphics.h
  10. 10. Stdio.hstdio.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 streamPrintf() -prints to the standard output stream
  11. 11. Data Types in C :
  12. 12. 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
  13. 13. If Statement :This is a conditional statement used in C tocheck condition or to control the flow ofexecution of statements. Syntax:if(condition) {statements; }
  14. 14. 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; }
  15. 15. 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
  16. 16. While loopIt is used to repeat a block of statements until condition is true. Syntax: while(condition) { statements; increment/decrement; }
  17. 17. For loopOne 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; } }
  18. 18. If this presentation helped you, please visit our page and like it. Thanks in | |
  19. 19. Contact Us