SlideShare a Scribd company logo
20CSS01 – Programming for Problem Solving
• Easy to learn & Opportunity to work on open source projects.
• Can be compiled on variety of computers
• Structured language
• Extensible by adding functions
• Understand the internal architecture of a computer, how computer stores and
retrieves information.
• Easier to learn other programming languages like Java, Python, etc.
• Some of the largest open-source projects Linux kernel, Python interpreter,
SQLite database, etc. are written in C
Why C Became Popular? Or Why Learn C ?
Compiler, Interpreter & Assembler
• A computer understands instructions in machine code, i.e. in the form of 0s
and 1s. It is a tedious task to write a computer program directly in machine
code. The programs are written mostly in high-level languages are called
source code.
• These source code cannot be executed directly by the computer and must be
converted into machine language to be executed.
• Compilers & Interpreters translate programs written in high-level languages
into machine code that a computer understands.
• Assemblers translate programs written in low-level or assembly language
into machine code and its machine-dependent
C Compiler
• The source code written in source file is the human readable source
for your program. It needs to be "compiled", into machine language
so that your CPU can actually execute the program as per the
instructions given.
• The compiler compiles the source codes into final executable
programs.
• The most frequently used and free available compiler is the GNU
C/C++ compiler,
• Ctrl-F9. – Compilation ; Alt + F9 - Run
Structure of a C program
Documentation Section
• We can give commands about program like author name,
creation or modified date.
• The information written in between /* */ or // is called as
comment line.
• These lines are not considered by the compiler while executing.
Preprocessor Directives
The C preprocessor is a macro processor that is used automatically
by the C compiler to transform your program before actual
compilation (Proprocessor direcives are executed before
compilation.).
It is called a macro processor because it allows you to define macros
Preprocessing directives are lines in your program that start
with #. The # is followed by an identifier that is the directive name.
For example, #define is the directive that defines a macro.
Eg :
• #include
• #define
Header Files Inclusion or Linker section
• The first and foremost component is the inclusion of the Header files in a C
program.
• A header file is a file with extension .h which contains C function declarations and
macro definitions to be shared between several source files.
Some of C Header files:
– stddef.h – Defines several useful types and macros.
– stdint.h – Defines exact width integer types.
– stdio.h – Defines core input and output functions
– stdlib.h – Defines numeric conversion functions, pseudo-random network
generator, memory allocation
– string.h – Defines string handling functions
– math.h – Defines common mathematical functions
• Main Method Declaration: The next part of a C program is to declare the main()
function
• Variable Declaration:
⮚ It refers to the variables that are to be used in the function.
⮚ In the C program, no variable can be used without being declared and to be
declared before any operation in the function.
• Body : The body of a function in the C program, refers to the operations that are
performed in the functions.
It can be anything like manipulations, searching, sorting, printing, etc.
int main()
{
int a;
printf("%d“,a);
}
Character Set
• The character set refers to a set of all the valid characters that we can use in the
source program for forming words, expressions, and numbers.
• It denotes any alphabet, digit or special symbol used to represent information.
• They include digits, alphabets, special symbols, etc. The C language provides
support for about 256 characters.
• The characters in C are grouped into the following two categories:
1. Source character set
a. Alphabets b. Digits
c. Special Characters d. White Spaces
2. Execution character set - Escape Sequence
Source character set
Execution Character Set
• Certain ASCII characters are unprintable, which means they are not displayed on the
screen or printer. Those characters perform other functions aside from displaying text.
Examples are backspacing, moving to a newline, or ringing a bell.
• They are used in output statements. Escape sequence usually consists of a backslash
and a letter or a combination of digits.
• An escape sequence is considered as a single character but a valid character constant.
Execution characters set are always represented by a backslash () followed by a
character.
• Each one of character constants represents one character, although they consist of
two characters. These characters combinations are called as escape sequence.
Tokens
• The token is the smallest individual element in C. For `example, we cannot
create a sentence without using words; similarly, we cannot create a
program in C without using tokens in C.
• Therefore, we can say that tokens in C is the building block or the basic
component for creating a program in C language
Identifiers
• Used for naming variables, functions, arrays, structures, etc.
• Identifiers in C are the user-defined words.
• Identifiers cannot be used as keywords.
Rules while naming c identifiers
• The first character of an identifier should be either an alphabet or an underscore,
and then it can be followed by any of the character, digit, or underscore.
• It should not begin with any numerical digit.
• In identifiers, both uppercase and lowercase letters are distinct. Therefore, we can
say that identifiers are case sensitive.
• Commas or blank spaces cannot be specified within an identifier.
• The length of the identifiers should not be more than 31 characters.
• Identifiers should be written in such a way that it is meaningful, short, and easy to
read.

More Related Content

Similar to structure of a c program - slideshare.pptx (20)

PPT
Introduction To Programming subject1.ppt
uf88605
 
PPT
490450755-Chapter-2.ppt
ManiMala75
 
PPT
490450755-Chapter-2.ppt
ManiMala75
 
PPTX
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
MUHUMUZAONAN1
 
PPTX
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
DOCX
C and DS -unit 1 -Artificial Intelligence and ML.docx
msurfudeen6681
 
PDF
Learning the C Language
nTier Custom Solutions
 
PPTX
Copy of UNIT 2 -- Basics Of Programming.pptx
rahulrajbhar06478
 
PPT
Chapter-2 edited on Programming in Can refer this ppt
ANISHYAPIT
 
PDF
Rr
VK AG
 
PDF
C pdf
amit9765
 
PDF
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
PPTX
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
PPTX
Best Computer Institute in Pitampura, Delhi, Learn from Industry Experts.
Veridical Technologies
 
PDF
C PROGRAMMING p-1.pdf
D.K.M college for women
 
PPTX
C programming
preetikapri1
 
PPTX
Lecture 1
marvellous2
 
PPT
history of c.ppt
arpanabharani
 
PPTX
Introduction of c programming unit-ii ppt
JStalinAsstProfessor
 
Introduction To Programming subject1.ppt
uf88605
 
490450755-Chapter-2.ppt
ManiMala75
 
490450755-Chapter-2.ppt
ManiMala75
 
UNIT 5 C PROGRAMMING, PROGRAM STRUCTURE
MUHUMUZAONAN1
 
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
C and DS -unit 1 -Artificial Intelligence and ML.docx
msurfudeen6681
 
Learning the C Language
nTier Custom Solutions
 
Copy of UNIT 2 -- Basics Of Programming.pptx
rahulrajbhar06478
 
Chapter-2 edited on Programming in Can refer this ppt
ANISHYAPIT
 
Rr
VK AG
 
C pdf
amit9765
 
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
Best Computer Institute in Pitampura, Delhi, Learn from Industry Experts.
Veridical Technologies
 
C PROGRAMMING p-1.pdf
D.K.M college for women
 
C programming
preetikapri1
 
Lecture 1
marvellous2
 
history of c.ppt
arpanabharani
 
Introduction of c programming unit-ii ppt
JStalinAsstProfessor
 

Recently uploaded (20)

PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
community health nursing question paper 2.pdf
Prince kumar
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
Ad

structure of a c program - slideshare.pptx

  • 1. 20CSS01 – Programming for Problem Solving • Easy to learn & Opportunity to work on open source projects. • Can be compiled on variety of computers • Structured language • Extensible by adding functions • Understand the internal architecture of a computer, how computer stores and retrieves information. • Easier to learn other programming languages like Java, Python, etc. • Some of the largest open-source projects Linux kernel, Python interpreter, SQLite database, etc. are written in C Why C Became Popular? Or Why Learn C ?
  • 2. Compiler, Interpreter & Assembler • A computer understands instructions in machine code, i.e. in the form of 0s and 1s. It is a tedious task to write a computer program directly in machine code. The programs are written mostly in high-level languages are called source code. • These source code cannot be executed directly by the computer and must be converted into machine language to be executed. • Compilers & Interpreters translate programs written in high-level languages into machine code that a computer understands. • Assemblers translate programs written in low-level or assembly language into machine code and its machine-dependent
  • 3. C Compiler • The source code written in source file is the human readable source for your program. It needs to be "compiled", into machine language so that your CPU can actually execute the program as per the instructions given. • The compiler compiles the source codes into final executable programs. • The most frequently used and free available compiler is the GNU C/C++ compiler, • Ctrl-F9. – Compilation ; Alt + F9 - Run
  • 4. Structure of a C program
  • 5. Documentation Section • We can give commands about program like author name, creation or modified date. • The information written in between /* */ or // is called as comment line. • These lines are not considered by the compiler while executing. Preprocessor Directives The C preprocessor is a macro processor that is used automatically by the C compiler to transform your program before actual compilation (Proprocessor direcives are executed before compilation.). It is called a macro processor because it allows you to define macros
  • 6. Preprocessing directives are lines in your program that start with #. The # is followed by an identifier that is the directive name. For example, #define is the directive that defines a macro. Eg : • #include • #define
  • 7. Header Files Inclusion or Linker section • The first and foremost component is the inclusion of the Header files in a C program. • A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files. Some of C Header files: – stddef.h – Defines several useful types and macros. – stdint.h – Defines exact width integer types. – stdio.h – Defines core input and output functions – stdlib.h – Defines numeric conversion functions, pseudo-random network generator, memory allocation – string.h – Defines string handling functions – math.h – Defines common mathematical functions
  • 8. • Main Method Declaration: The next part of a C program is to declare the main() function • Variable Declaration: ⮚ It refers to the variables that are to be used in the function. ⮚ In the C program, no variable can be used without being declared and to be declared before any operation in the function. • Body : The body of a function in the C program, refers to the operations that are performed in the functions. It can be anything like manipulations, searching, sorting, printing, etc. int main() { int a; printf("%d“,a); }
  • 9. Character Set • The character set refers to a set of all the valid characters that we can use in the source program for forming words, expressions, and numbers. • It denotes any alphabet, digit or special symbol used to represent information. • They include digits, alphabets, special symbols, etc. The C language provides support for about 256 characters. • The characters in C are grouped into the following two categories: 1. Source character set a. Alphabets b. Digits c. Special Characters d. White Spaces 2. Execution character set - Escape Sequence
  • 11. Execution Character Set • Certain ASCII characters are unprintable, which means they are not displayed on the screen or printer. Those characters perform other functions aside from displaying text. Examples are backspacing, moving to a newline, or ringing a bell. • They are used in output statements. Escape sequence usually consists of a backslash and a letter or a combination of digits. • An escape sequence is considered as a single character but a valid character constant. Execution characters set are always represented by a backslash () followed by a character. • Each one of character constants represents one character, although they consist of two characters. These characters combinations are called as escape sequence.
  • 12. Tokens • The token is the smallest individual element in C. For `example, we cannot create a sentence without using words; similarly, we cannot create a program in C without using tokens in C. • Therefore, we can say that tokens in C is the building block or the basic component for creating a program in C language
  • 13. Identifiers • Used for naming variables, functions, arrays, structures, etc. • Identifiers in C are the user-defined words. • Identifiers cannot be used as keywords. Rules while naming c identifiers • The first character of an identifier should be either an alphabet or an underscore, and then it can be followed by any of the character, digit, or underscore. • It should not begin with any numerical digit. • In identifiers, both uppercase and lowercase letters are distinct. Therefore, we can say that identifiers are case sensitive. • Commas or blank spaces cannot be specified within an identifier. • The length of the identifiers should not be more than 31 characters. • Identifiers should be written in such a way that it is meaningful, short, and easy to read.