Professional Documents
Culture Documents
Chapter 3
Chapter 3
2. General Form of C
3. Parts of C Programming
4. Special Characters
5. Program Block
Translated to
Dialog box in
Dev-C++ editor
shows
compiling
process.
9 Prepared by Norhamreeza Abdul Hamid
Phase 3: Compiling a Program
Example
#include<stdio.h>
#include<conio.h>
#include “jam.h”
Example
void main( )
{ …………..}
Function
Statement
Declaration Control
Statement Statement
Types
Input /
Compound
Output
Statement
Statement
Rules
Case –sensitive
Cannot be used as identifier
Must be written in
or variables
small case
floating
point
integer
boolean
character
Data Types
32 Prepared by Norhamreeza Abdul Hamid
Data Types
•Represent any round numbers with +/- values
CODE: MEMORY:
char letter; letter
letter = 'C';
67
H e l l o \0
allDone finished
1 0
41
Prepared by Norhamreeza Abdul Hamid
Identifier (Standard)
42
Prepared by Norhamreeza Abdul Hamid
Identifier (Standard)
#include <stdio.h>
int main()
{
int h;
printf(“Please enter a number”);
scanf(“%d”, &h);
h = h*5;
printf(“The answer is %d”, h);
return 0;
}
43
Prepared by Norhamreeza Abdul Hamid
Identifier (Standard)
44
Prepared by Norhamreeza Abdul Hamid
Identifier (User-defined)
45
Prepared by Norhamreeza Abdul Hamid
Identifier (User-defined)
Valid identifiers
WHY?
Invalid identifiers
8Century BIC 1033 Two*four
‘Sixsense’ void
WHY?
WHY? WHY?
46 Prepared by Norhamreeza Abdul Hamid
Identifier (User-defined)
Constant
Reserved word const float pi = 3.142;
Value
Constant
Reserved word #define pi = 3.142;
Value
#define minimum 0;
#define MAX 100;
data_type variable_name;
int number;
float weight;
char alphabet;
Constant declaration
Variable declaration
Initialize
variable
Interactive
variable
Misplaced else.
Declaration sytanx error
Undefined symbol ‘_main’ in module.
Statement missing in function main()
y = 2x + a - 6