Lecture 6 PF
Lecture 6 PF
Lecture 6 PF
FUNDAMENTALS
LECTURE # 06
C Development
Environment
Disk
Disk
Pre-processor program
processes the code.
Disk
Disk
Disk
Disk
C Development
Environment
C Program Structure
The output
Preprocessor directives
#include
#define
Function main
void main(void)
main(void)
main( )
return 0;
Statement
statement
statement
statement
Statement cont
Declaration
The
Executable statements
Program
C program skeleton
Preprocessor directives
Function main
void main(void)
Start of segment
{
statement(s);
}
End of segment
Identifiers
int my_name;
my_name
variable
name
Example
H2o
Number1
_area
XsquAre
My_num
R*S+T
#@x%!!
struct; printf;
My height
Tax != tax
Variables
Example:
num
= 5;
int
float
double
char
int
float
keyword: float
float height;
height = 1.72;
double
keyword: double
double valuebig;
char
Numeric digits: 0 - 9
Lowercase/uppercase letters: a - z and A - Z
Space (blank)
Special characters: , . ; ? / ( ) [ ] { } * & % ^ < > etc
single character
keyword: char
char my_letter;
my_letter = 'U';
Constants
Integer constants
Constants cont
Character constants
A
#define
#include <stdio.h>
#Include <conio.h>
#define pi 3.412
void main()
{
double height, radius, base, volume;
printf(Enter the height and radius of the cone:);
scanf(%lf %lf, &height, &radius);
base = pi * radius * radius;
volume = (1.0/3.0) * base * height;
printf(\nThe volume of a cone is %f , volume);
getch();
}
Summary
Preprocessor directives,
curly braces, main (),
semicolon, comments, double quotes
Task to do: