intro_to_turbo_c
intro_to_turbo_c
Introduction
Books
C provides:
Efficiency, high performance and high quality
Provide functionality through rich set of function libraries
Gateway for other professional languages like C C++ Java
C is used:
System software, Compilers, Editors
Graphics and Geometry
Databases, operating systems, device drivers
Also used in application programs
Software Development Method
Requirement Specification
– Problem Definition
Analysis
– Refine, Generalize the problem definition
Design
– Develop Algorithm: (A formula or set of steps for solving a
particular problem)
Implementation
– Write Code
Verification and Testing
– Test and Debug the code
How do you write a program?
Steps in learning C
Constants
Alphabets Instruction Program
Variables
Digits
Keywords
Special-symbols
Sample Pseudo code
Task: add two numbers
Pseudo code (Algorithm) :
1. Start
2. Get two numbers
3. Add them (a + b)
4. Print the answer
5. End
What does a flowchart look like?
Pseudo code Start
(Algorithm) :
Get 2 numbers
1. Start
2. Get two numbers
3. Add them (A + B) A+B
4. Print the answer
5. End
Print answer
End
Flow Chart symbols
START/END
INPUT/OUTPUT
PROCESS
DECISION
Integrated Development Environments
16
Header Files
#include <stdio.h>
void main(void)
{
printf("Hello World");
}
Simple C Program
/* A first C Program*/
Preprocessor directive
void main() Main Function
{ Opening bracket
} Closing Bracket
Simple C Program
Line 1: #include <stdio.h>
/*….
…….*/
It is used to increase the readability of the program.
program.
Comment cannot be nested
example:
/* A first C Program*/
Running C Program
Type a program
Save it
Compile the program – This will generate an exe
file (executable)
Run the program (Actually the exe created out of
compilation will run and not the .c file)
In different compiler we have different option for
compiling and running. We give only the
concepts.
The C character Set
•A character denotes any alphabet, digit
or special symbol used to represent
information.
Digits 0,1,2,3,4,5,6,7,8,9
Example: 3x + y = 20
3 & 20 are constants, which cannot change
x & y can vary or change hence are called variables
Keywords
• Keywords are the words whose meaning has
already been explained to the C compiler
• Sometimes called reserved words.
• They cannot be used as variable names.
• There are only 32 keywords available in c
\n new line
\t tab
\a alert
\\ backslash
\” double quote
\0 Null
\b Backspace
Data Types
Preprocessor
Compiler
Linker
Executable File
Keywords
Sometimes called reserved words.
Are defined as a part of the C language.
Can not be used for anything else!
32 keywords in C
Examples:
– Int
– void
– while
– for