SlideShare a Scribd company logo
CHAPTER 3
OUTCOMES: 
Student should be able to: 
0Explain the general form 0f C 
structure 
0Write, Compile & Execute of C 
programme 
2
The general form of C 
programme 
3
Follow 3 steps: 
0 Enter the programme 
0 Compile the programme 
0 Run the programme 
2 terms: 
0 Source code – the human readable form of the 
programme. It is stored in a text file 
0 Object code – the executable form of the programme 
created by a compiler 
4
Write the general form of C 
programme 
0 Entering the programme 
The name of the file that holds the source code for the 
programme is technically arbitrary 
C programme are normally contained in files that use 
the file extension (.cpp) 
5
0 Compiling the programme 
You can compile your .cpp file depends on your 
compiler & what option you are using 
e.g: 
Microsoft Visual C++ Express Edition  provide 2 
different ways of compiling a programme: the 
command-line compiler & the Integrated Development 
Environment (IDE) 
6
0 Execute the debugged programme 
After a C programme has been compiled, it is ready to 
be run 
Since the output from a C compiler is executed object 
code, to run the programme, simply enter its name at 
the command prompt 
7
Pre-processor directives and 
header files 
0 Pre-processor 
Is the directive to enables the programme to use certain 
function contained in the external file such as <stdio.h> 
0 Header file 
Contain specific functions that used to accomplish the 
programming task 
e.g: ctype.h, math.h 
8
#include 
0 replaces by the whole content of specified file 
0 2 ways to specify a file: 
9 
#include “stdio.h” 
the file is looked for from the same directory in which the file 
that includes the directive is 
#include <stdio.h> 
the file is directly looked for in the default directories where 
the compiler is configured to look for standard header files
serves to generate define constants or macros 
10 
#define 
#define variable_name value 
#define pepsi 2.50 
#define grapes 8.50 
Example:
Create block {…} in Main 
function 
a function is a block of statements that is part of large 
programmes 
0 Function main ( ) 
Must have at least the function main ( ) 
Must have a body enclosed in braces { } 
11
0 Function block { } 
the function body  called block can be any size 
{ - begin block 
} - end block 
12
Create return statement in 
programmes 
0 terminates the execution of a function and returns 
control to the calling function 
0 can also return a value to the calling function 
13
Comments 
0 useful for a variety of purposes 
0 provide the easiest way to point out specific parts of 
code 
0 2 forms: 
//  single line comment 
/* …..*/  multi line comment 
14
Single line comment 
0 useful for simple ‘side’ notes that explain what certain 
parts of the code do 
0 places: next to variable declarations & next to pieces 
of code that may need explanation 
15
0 Example: 
//this is first line 
//this is second line 
//this is third line 
//this is fourth line 
16
Multi line comment 
0 most useful for long explanation of code 
0 can be use as: 
copyright/licensing notices 
explain the purpose of a path of code 
0 can be useful in two aspects: 
make functions easier to understand 
easier to spot errors in code 
17
0 Example: 
/*this is first line 
this is second line 
this is third line 
this is fourth line*/ 
18
Create comments in programme 
19 
/*This is a programme that computes the sum of two integer 
numbers*/ 
#include<stdio.h> //This is a preprocessor 
main( ) //function main 
{ //Begin block 
int x, y, sum; //This is declaration of variable 
printf(Enter first number:”); //User output 
scanf(“%d”,&x); //User input 
printf(Enter second number:”); 
scanf(“%d”,&x); 
sum= x+y; //Operation for sum of two numbers 
printf(“nSum = %d”, sum); //Output 
return 0; //Return statement 
} //End block

More Related Content

PPT
CHAPTER 1
PDF
Computer programming chapter ( 3 )
PDF
Computer programming chapter ( 4 )
PPT
Chapter3
DOCX
C programming languag for cse students
PPT
OVERVIEW OF ‘C’ PROGRAM
PPT
Intro to c++
PPTX
What is token c programming
CHAPTER 1
Computer programming chapter ( 3 )
Computer programming chapter ( 4 )
Chapter3
C programming languag for cse students
OVERVIEW OF ‘C’ PROGRAM
Intro to c++
What is token c programming

What's hot (20)

PDF
Handout#11
PPT
Lecture 1
PPTX
Introduction to C Programming
PDF
Handout#01
PDF
Hands-on Introduction to the C Programming Language
PDF
Content
PPT
Beginner C++ easy slide and simple definition with questions
PPTX
Chapter 2
PPT
Chapter2
DOCX
C language industrial training report
PDF
Introduction of c language
PPTX
Principles of object oriented programing
PPTX
C_Programming_Notes_ICE
PDF
Handout#02
PDF
Handout#03
DOC
PDF
C programming course material
PDF
Introduction to Computer and Programing - Lab2
PPT
C program
PDF
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
Handout#11
Lecture 1
Introduction to C Programming
Handout#01
Hands-on Introduction to the C Programming Language
Content
Beginner C++ easy slide and simple definition with questions
Chapter 2
Chapter2
C language industrial training report
Introduction of c language
Principles of object oriented programing
C_Programming_Notes_ICE
Handout#02
Handout#03
C programming course material
Introduction to Computer and Programing - Lab2
C program
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
Ad

Viewers also liked (13)

PPTX
c programme
PPTX
Basic C concepts.
PDF
C Language Program
PPT
Can my English course be translated to Tamil language?
PPT
8.1 alogorithm & prolem solving
PPSX
Complete C programming Language Course
PPTX
Introduction to Basic C programming 02
PPTX
Structure in C
PPTX
FUNDAMENTAL OF C
PPT
C ppt
PPTX
PDF
Lecture18 structurein c.ppt
c programme
Basic C concepts.
C Language Program
Can my English course be translated to Tamil language?
8.1 alogorithm & prolem solving
Complete C programming Language Course
Introduction to Basic C programming 02
Structure in C
FUNDAMENTAL OF C
C ppt
Lecture18 structurein c.ppt
Ad

Similar to CHAPTER 3 (20)

PPTX
basic program
PPTX
C Programming UNIT 1.pptx
PDF
Introduction To C++ programming and its basic concepts
PDF
C class basic programming 1 PPT mayanka (1).pdf
PPTX
Introduction to cpp language and all the required information relating to it
PDF
Cp week _2.
PPTX
C Programming Language Step by Step Part 2
PDF
ICT1002-W8-LEC-Introduction-to-C.pdf
PPTX
C++ AND CATEGORIES OF SOFTWARE
PPTX
C++ Constructs.pptx
PPTX
C++Basics2022.pptx
PDF
2. Consider the following C program #define M ... #define N ....pdf
PPTX
Basic c programming and explanation PPT1
PPTX
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
PPTX
Introduction-to-C-Part-1.pptx
PPTX
Stucture of c program
PPTX
Lecture 1
PPTX
Functions and Header files ver very useful
PPT
Fp201 unit2 1
basic program
C Programming UNIT 1.pptx
Introduction To C++ programming and its basic concepts
C class basic programming 1 PPT mayanka (1).pdf
Introduction to cpp language and all the required information relating to it
Cp week _2.
C Programming Language Step by Step Part 2
ICT1002-W8-LEC-Introduction-to-C.pdf
C++ AND CATEGORIES OF SOFTWARE
C++ Constructs.pptx
C++Basics2022.pptx
2. Consider the following C program #define M ... #define N ....pdf
Basic c programming and explanation PPT1
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1.pptx
Stucture of c program
Lecture 1
Functions and Header files ver very useful
Fp201 unit2 1

More from mohd_mizan (7)

PDF
Mind map chapter 4
PDF
Dbs 1012 synopsis
PDF
Chapter 4 work, energy and power
PPTX
CHAPTER 4
PPTX
CHAPTER 6
PPTX
CHAPTER 5
PPTX
CHAPTER 2
Mind map chapter 4
Dbs 1012 synopsis
Chapter 4 work, energy and power
CHAPTER 4
CHAPTER 6
CHAPTER 5
CHAPTER 2

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Insiders guide to clinical Medicine.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
PPH.pptx obstetrics and gynecology in nursing
102 student loan defaulters named and shamed – Is someone you know on the list?
STATICS OF THE RIGID BODIES Hibbelers.pdf
Anesthesia in Laparoscopic Surgery in India
O5-L3 Freight Transport Ops (International) V1.pdf
Final Presentation General Medicine 03-08-2024.pptx
Supply Chain Operations Speaking Notes -ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Institutional Correction lecture only . . .
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Abdominal Access Techniques with Prof. Dr. R K Mishra
Insiders guide to clinical Medicine.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Cell Types and Its function , kingdom of life
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
01-Introduction-to-Information-Management.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial diseases, their pathogenesis and prophylaxis
PPH.pptx obstetrics and gynecology in nursing

CHAPTER 3

  • 2. OUTCOMES: Student should be able to: 0Explain the general form 0f C structure 0Write, Compile & Execute of C programme 2
  • 3. The general form of C programme 3
  • 4. Follow 3 steps: 0 Enter the programme 0 Compile the programme 0 Run the programme 2 terms: 0 Source code – the human readable form of the programme. It is stored in a text file 0 Object code – the executable form of the programme created by a compiler 4
  • 5. Write the general form of C programme 0 Entering the programme The name of the file that holds the source code for the programme is technically arbitrary C programme are normally contained in files that use the file extension (.cpp) 5
  • 6. 0 Compiling the programme You can compile your .cpp file depends on your compiler & what option you are using e.g: Microsoft Visual C++ Express Edition  provide 2 different ways of compiling a programme: the command-line compiler & the Integrated Development Environment (IDE) 6
  • 7. 0 Execute the debugged programme After a C programme has been compiled, it is ready to be run Since the output from a C compiler is executed object code, to run the programme, simply enter its name at the command prompt 7
  • 8. Pre-processor directives and header files 0 Pre-processor Is the directive to enables the programme to use certain function contained in the external file such as <stdio.h> 0 Header file Contain specific functions that used to accomplish the programming task e.g: ctype.h, math.h 8
  • 9. #include 0 replaces by the whole content of specified file 0 2 ways to specify a file: 9 #include “stdio.h” the file is looked for from the same directory in which the file that includes the directive is #include <stdio.h> the file is directly looked for in the default directories where the compiler is configured to look for standard header files
  • 10. serves to generate define constants or macros 10 #define #define variable_name value #define pepsi 2.50 #define grapes 8.50 Example:
  • 11. Create block {…} in Main function a function is a block of statements that is part of large programmes 0 Function main ( ) Must have at least the function main ( ) Must have a body enclosed in braces { } 11
  • 12. 0 Function block { } the function body  called block can be any size { - begin block } - end block 12
  • 13. Create return statement in programmes 0 terminates the execution of a function and returns control to the calling function 0 can also return a value to the calling function 13
  • 14. Comments 0 useful for a variety of purposes 0 provide the easiest way to point out specific parts of code 0 2 forms: //  single line comment /* …..*/  multi line comment 14
  • 15. Single line comment 0 useful for simple ‘side’ notes that explain what certain parts of the code do 0 places: next to variable declarations & next to pieces of code that may need explanation 15
  • 16. 0 Example: //this is first line //this is second line //this is third line //this is fourth line 16
  • 17. Multi line comment 0 most useful for long explanation of code 0 can be use as: copyright/licensing notices explain the purpose of a path of code 0 can be useful in two aspects: make functions easier to understand easier to spot errors in code 17
  • 18. 0 Example: /*this is first line this is second line this is third line this is fourth line*/ 18
  • 19. Create comments in programme 19 /*This is a programme that computes the sum of two integer numbers*/ #include<stdio.h> //This is a preprocessor main( ) //function main { //Begin block int x, y, sum; //This is declaration of variable printf(Enter first number:”); //User output scanf(“%d”,&x); //User input printf(Enter second number:”); scanf(“%d”,&x); sum= x+y; //Operation for sum of two numbers printf(“nSum = %d”, sum); //Output return 0; //Return statement } //End block