SlideShare a Scribd company logo
1 of 22
Programming in C
Core Course
Course Instructor
Dr. Murali Malijeddi
Professor
Dept. of ECE, CUTM AP
Developing a Software
Translators
Translators
Characteristics of C
•C Language is a middle level language.
•It has the simplicity of a high level language
•It has the power of low level language.
Characteristics of C
• C is small language
• Consisting of only 32 English words known as keywords
(if, else, for, break etc.)
• The power of C is augmented by the library functions provided
with it.
• Moreover, the language is extendible
• It allows the users to add their own library functions to the library.
• The programs written in C are portable
Structure of a C Program
•C program is a collection of one or more - functions.
•Every function is a collection of statements
•A function performs some specific task.
•The general structure of C program is:
Structure of a C Program
Structure of a C Program
•Comments can be placed anywhere in a program
•Comments are enclosed between the delimiters
/* */
•E.g., /* Blah Blah… blah... */
•Comments are generally used for documentation purposes.
Structure of a C Program
• Preprocessor directives are processed through Preprocessor
before the C source code passes through Compiler.
• The most commonly used preprocessor directives are
#include and #define
• #include is used for including header files.
• #define is used to define symbolic constants and macros.
• Note:
• Preprocessor directives begin with #.
• Only white-space and comments may appear a Preprocessor directives in a program.
Structure of a C Program
Structure of a C Program
• Every C program has one or more functions.
• If a program has only one function then it must be main()
• Execution of every C program starts with main() function.
• main() function has two parts:
• declaration of local variables
• and statements
•
Structure of a C Program
•The scope of the local variable is local to that function only.
•Statements in the main function are executed one by one.
•Other functions are the user-defined functions, which also
have local variables and C statements.
•Other functions can be defined before or after main().
Structure of a C Program
•It may be possible that some variables have to be used in
many functions, so it is necessary to declare them globally.
•These variables are called global variables.
Environment For C
•The steps for the execution of C program are as-
1. Program creation
2. Program compilation
3. Program execution
Environment For C
•The C programs are written in mostly two environments:
1. UNIX Environment
2. Windows (MS-DOS) Environment
•MS-DOS environment creation, compilation and execution
can be done using command line or IDE (integrated
Development Environment).
Unix Environment
•Generally a command line C compiler is provided with the
UNIX operating system.
•This compiler is named gcc or cc,
Unix Environment - Program creation
•In UNIX environment, file can be created with "vi editor”
•$ vi filename.c
•Here $ is the Unix prompt.
•The file can be saved by pressing
• ESC and SHIFT+zz
Or
• ESC and :wq + Enter
Unix Environment - Program compilation
• Two different ways are there:
Method - 1)
• After creation of C program, it can be compiled as:
$ gcc filename.c
• Program has mathematical function then it is compiled as:
$ gcc filename.c -lm
• After compilation, the executable code is stored in the file 'a.out'.
•
Unix Environment - Program compilation
Method - 2)
$ gcc filename.c -o ProgramName
•Program has mathematical function then
$ gcc filename.c -lm -o ProgramName
•After compilation, the executable code is stored in the file
'ProgramName'.
Unix Environment - Program execution
•After the compilation of program, it can be executed as:
$ ./a.out
Or
$ ./ProgramName
C Programming Lecture 2 - Structure of a C Program.pptx

More Related Content

Similar to C Programming Lecture 2 - Structure of a C Program.pptx

Computer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptxComputer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptx
fatahozil
 

Similar to C Programming Lecture 2 - Structure of a C Program.pptx (20)

chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
COM1407: Introduction to C Programming
COM1407: Introduction to C Programming COM1407: Introduction to C Programming
COM1407: Introduction to C Programming
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Computer programming - turbo c environment
Computer programming - turbo c environmentComputer programming - turbo c environment
Computer programming - turbo c environment
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 
CS3251-_PIC
CS3251-_PICCS3251-_PIC
CS3251-_PIC
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net Framework
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
C Programming[Sample]
C Programming[Sample]C Programming[Sample]
C Programming[Sample]
 
C.pdf
C.pdfC.pdf
C.pdf
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Understanding C and its Applications.pdf
Understanding C and its Applications.pdfUnderstanding C and its Applications.pdf
Understanding C and its Applications.pdf
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Computer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptxComputer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptx
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translators
 
Unit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptxUnit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptx
 
Basic Structure of C Language and Related Term
Basic Structure of C Language  and Related TermBasic Structure of C Language  and Related Term
Basic Structure of C Language and Related Term
 

Recently uploaded

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 

Recently uploaded (20)

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 

C Programming Lecture 2 - Structure of a C Program.pptx

  • 1. Programming in C Core Course Course Instructor Dr. Murali Malijeddi Professor Dept. of ECE, CUTM AP
  • 5. Characteristics of C •C Language is a middle level language. •It has the simplicity of a high level language •It has the power of low level language.
  • 6. Characteristics of C • C is small language • Consisting of only 32 English words known as keywords (if, else, for, break etc.) • The power of C is augmented by the library functions provided with it. • Moreover, the language is extendible • It allows the users to add their own library functions to the library. • The programs written in C are portable
  • 7. Structure of a C Program •C program is a collection of one or more - functions. •Every function is a collection of statements •A function performs some specific task. •The general structure of C program is:
  • 8. Structure of a C Program
  • 9. Structure of a C Program •Comments can be placed anywhere in a program •Comments are enclosed between the delimiters /* */ •E.g., /* Blah Blah… blah... */ •Comments are generally used for documentation purposes.
  • 10. Structure of a C Program • Preprocessor directives are processed through Preprocessor before the C source code passes through Compiler. • The most commonly used preprocessor directives are #include and #define • #include is used for including header files. • #define is used to define symbolic constants and macros. • Note: • Preprocessor directives begin with #. • Only white-space and comments may appear a Preprocessor directives in a program.
  • 11. Structure of a C Program
  • 12. Structure of a C Program • Every C program has one or more functions. • If a program has only one function then it must be main() • Execution of every C program starts with main() function. • main() function has two parts: • declaration of local variables • and statements •
  • 13. Structure of a C Program •The scope of the local variable is local to that function only. •Statements in the main function are executed one by one. •Other functions are the user-defined functions, which also have local variables and C statements. •Other functions can be defined before or after main().
  • 14. Structure of a C Program •It may be possible that some variables have to be used in many functions, so it is necessary to declare them globally. •These variables are called global variables.
  • 15. Environment For C •The steps for the execution of C program are as- 1. Program creation 2. Program compilation 3. Program execution
  • 16. Environment For C •The C programs are written in mostly two environments: 1. UNIX Environment 2. Windows (MS-DOS) Environment •MS-DOS environment creation, compilation and execution can be done using command line or IDE (integrated Development Environment).
  • 17. Unix Environment •Generally a command line C compiler is provided with the UNIX operating system. •This compiler is named gcc or cc,
  • 18. Unix Environment - Program creation •In UNIX environment, file can be created with "vi editor” •$ vi filename.c •Here $ is the Unix prompt. •The file can be saved by pressing • ESC and SHIFT+zz Or • ESC and :wq + Enter
  • 19. Unix Environment - Program compilation • Two different ways are there: Method - 1) • After creation of C program, it can be compiled as: $ gcc filename.c • Program has mathematical function then it is compiled as: $ gcc filename.c -lm • After compilation, the executable code is stored in the file 'a.out'. •
  • 20. Unix Environment - Program compilation Method - 2) $ gcc filename.c -o ProgramName •Program has mathematical function then $ gcc filename.c -lm -o ProgramName •After compilation, the executable code is stored in the file 'ProgramName'.
  • 21. Unix Environment - Program execution •After the compilation of program, it can be executed as: $ ./a.out Or $ ./ProgramName