260 likes | 769 Views
FORMAL LETTER. Fahri bin Fahmi No2 Jalan Masjid 35900 Proton City, Tanjung Malim --------------------------------------------------------------------------------------------------------- Cikgu Rohani binti Kadir SMK Proton City
E N D
FORMAL LETTER Fahri bin Fahmi No2 JalanMasjid 35900 Proton City, TanjungMalim --------------------------------------------------------------------------------------------------------- CikguRohanibintiKadir SMK Proton City 35900 Proton City, TanjungMalim 25 January 2010 Dear teacher, ABSENT To refer as above, I can’t attend to the school for 2 days (21 and 22 January 2010) because I am not feeling well. I will be back to school on 25 January 2010. Thank you. Yours sincerely, Fahri bin Fahmi
UNIT 4.3 FUNDAMENTALS OF C LANGUAGE 4.3.1 STRUCTURE OF C PROGRAMS
LEARNING OBJECTIVES : • At the end of this lesson, students should be able to : • Explain the structure of C programs Write the simple program using C language
INTRODUCTION C Language : programming language developed at AT&T Bell laboratories by Dennis Ritchi. named C because it followed an earlier PL named B. structured language as it enforces a logical structure in the program Reliable, simple and easy to use • PL have words, symbols and rules (known as the syntax)
4.3.1 STRUCTURE OF C PROGRAMS <comment entry> <preprocessor directives> main() { <declarations>; <C statements>; }
Comments • Can be placed anywhere /* This is a comment */ • Nested comments will be flagged as errors by the compiler. /*/* This is a wrong comment */*/
Preprocessor Directive • Syntax : #include <filename> • Example : #include <stdio.h> • stdio.h : will include all standard input-output functions • #include < conio.h>
main() • The most important function, which must be present in all the programs. • Programs will always start executing from this function. • A program can have only one main() function.
{ • Stated the starting for main function • Every function must have at least one pair block opener ( { ) and closer ( } )
Variable Declaration • All the variables that are used in a program must be declared. • Example : int x, char a, float mark data type variable
C Statements Printf (“I’m a good girl”) • Displays the specified string on the screen. Scanf (“%d”, age) To get the value from the user clrscr() • Will clear the screen content.
C PROGRAM Example 1 /* First day to school*/ #include<stdio.h> main() { int a; printf (“Enjoy the first day”); }
Example 2 /* Learn C program*/ #include<stdio.h> main() { printf (“It’s so easy programming language”); }
Example 3 /*Easy number*/ #include <stdio.h> main() { int x; /*variable declared*/ printf (“\n Enter a number =”); Scanf (“%d”, x); /*user enter a number*/ }
What is the C structure components? • How to build up the C program?
MutiaraKata “Bukansemuaorangbodohitubodoh, sebenarnyadiabodohkeranamembenarkandirinyauntukmenjadibodoh” “Kita tidakperlumenyesalkalauorang lain tidakmengetahuipengetahuankita, kitaharusbersusahhatikalaukitatidakmengetahuipengetahuanorang lain” -Dr. HM TuahIskandar Al-haj