SlideShare una empresa de Scribd logo
1 de 13
Programming in C
A little history:
 1970’s
 Unix
 C, from BCPL (Thompson and Ritchie)
 C programming Language
 Widely used like the others: Fortran, Pascal
 Main form of language for system programming
 Available on any machine with C compiler and
library
Some Characteristics:
 Scope:
 Intended:

HPC, OS, general programming

Typically, long developing cycle

very platform dependent
 Not intended: web, scripting, data processing
 Features:
 Close interaction with system

Standard library (user-level only),

no other fancy stuff: networking, memory, graphics
 Extensive use of pointers
 Procedure (OOB) programming, strictly pass by value
Sample 1:
/* Hello World! */
#include <stdio.h>
int main()
{
printf(“Hello World!n”);
return 0;
}
Walk through:
 C program: hello.c
 emacs, vi, vim, pico, joe …
 But text editors only. No word processor
 Preprocessing: hello.s, assembly code
 cc -S hello.c
 Compilation: hello.o, a binary file
 cc -c hello.s
 Linking: a.out or hello, an executable file
 cc hello.o
 cc -o hello hello.o
 Loading (dynamical linking) and execution: ./hello
 ./a.out
 ./hello
Programming (Editing)
 C program: hello.c
 emacs, vi, vim, pico, joe …
 But text editors only. No word processor
Compile:
 Preprocessing: hello.s, assembly code
 cc -S hello.c
 Can you take a look at hello.s and compare to hello.c?
 Compilation: hello.o, a binary file
 cc -c hello.s
 Do you know how to take a look at hello.o?
 Linking: a.out or hello, an executable file
 cc hello.o
 cc -o hello hello.o
 Want to look at the executable, hello?
Run:
 Loading (dynamical linking) and execute: ./hello
 ./a.out
 ./hello
 What you do with java programs?
 What computer does to run your program?
Sample 1 Dissection:
 What it has?
 A function definition: main
 A line of comment
 A line of preprocessor directive
 An output statement
 A return clause
 What it does?
 Ask the computer to say hello to the world.
 What it does not do?
 It seems not computing!!
 No real work

not taking input

does not change any value
Sample 2:
#include <stdio.h>
#define MAGIC 10
int main(void)
{
int i, fact, quotient;
while (i++ < 3) {
printf(”Guess a factor of MAGIC larger than 1: ");
scanf("%d”, &fact);
quotient = MAGIC % fact;
if (0 == quotient)
printf(”You got it!n”);
else
printf(”Sorry, You missed it!n”);
}
return 0;
}
Sample 2 Dissection:
 What more it has?
 Macro definition
 Variable declaration
 Operations represented by operators
 Conditional computation
 Input Processing
 Loops: three chances
Syntax Dissection:
 What is syntax?
 m-w.com:

the way in which linguistic elements (as words) are put together
to form constituents (as phrases or clauses)
 How to put your C elements together into a program?
 Variable declaration,
 Identifier: case, keywords, style
 datatype specification

char, short, int, long, float, double
 Operators:
 +, -, *, /, %, ++, --; >, <, ==, ; &, |, …
 Priority and Precedence
 Associativity
More Syntax Dissection:
 Preprocessor directive
 macro
 header file inclusion
 Loop constructs
 for, while, do-while, break, continue, label--go;
 Conditional statements
 If, else, else if, switch, break
 Function definition
 return type, parameter definition, parameter passing
 Standard library and function calls
 Take home practice:
 Walk through the following steps with sample 2

preprocessing, compilation, linking, loading/execute

Modify and repeat once more if you can

Más contenido relacionado

La actualidad más candente

Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
Chapter 1: Introduction
Chapter 1: IntroductionChapter 1: Introduction
Chapter 1: IntroductionEric Chou
 
To GO or not to GO
To GO or not to GOTo GO or not to GO
To GO or not to GOsuperstas88
 
C++17 std::filesystem - Overview
C++17 std::filesystem - OverviewC++17 std::filesystem - Overview
C++17 std::filesystem - OverviewBartlomiej Filipek
 
The GNOME way - What can we learn from and within the Open Documentation World
The GNOME way - What can we learn from and within the Open Documentation WorldThe GNOME way - What can we learn from and within the Open Documentation World
The GNOME way - What can we learn from and within the Open Documentation WorldRadina Matic
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programmingExotel
 
introduction to c programming language
introduction to c programming languageintroduction to c programming language
introduction to c programming languagesanjay joshi
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeksAashutoshChhedavi
 
Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018Timothé Larivière
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about goDvir Volk
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#Sireesh K
 
Core Java Meetup #9 - Quiz Questions - 6th May
Core Java Meetup #9 - Quiz Questions - 6th MayCore Java Meetup #9 - Quiz Questions - 6th May
Core Java Meetup #9 - Quiz Questions - 6th MayCodeOps Technologies LLP
 
Introduction to Go language
Introduction to Go languageIntroduction to Go language
Introduction to Go languageTzar Umang
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programmingMahmoud Masih Tehrani
 
C++ vs python the best ever comparison
C++ vs python the best ever comparison C++ vs python the best ever comparison
C++ vs python the best ever comparison calltutors
 
C# and the Evolution of a Programming Language
C# and the Evolution of a Programming LanguageC# and the Evolution of a Programming Language
C# and the Evolution of a Programming LanguageJacinto Limjap
 

La actualidad más candente (20)

Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Chapter 1: Introduction
Chapter 1: IntroductionChapter 1: Introduction
Chapter 1: Introduction
 
C++ language
C++ languageC++ language
C++ language
 
Vocabulary Types in C++17
Vocabulary Types in C++17Vocabulary Types in C++17
Vocabulary Types in C++17
 
To GO or not to GO
To GO or not to GOTo GO or not to GO
To GO or not to GO
 
C++17 std::filesystem - Overview
C++17 std::filesystem - OverviewC++17 std::filesystem - Overview
C++17 std::filesystem - Overview
 
A Tour of Go - Workshop
A Tour of Go - WorkshopA Tour of Go - Workshop
A Tour of Go - Workshop
 
The GNOME way - What can we learn from and within the Open Documentation World
The GNOME way - What can we learn from and within the Open Documentation WorldThe GNOME way - What can we learn from and within the Open Documentation World
The GNOME way - What can we learn from and within the Open Documentation World
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programming
 
Python vs c++ ppt
Python vs c++ pptPython vs c++ ppt
Python vs c++ ppt
 
introduction to c programming language
introduction to c programming languageintroduction to c programming language
introduction to c programming language
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#
 
Core Java Meetup #9 - Quiz Questions - 6th May
Core Java Meetup #9 - Quiz Questions - 6th MayCore Java Meetup #9 - Quiz Questions - 6th May
Core Java Meetup #9 - Quiz Questions - 6th May
 
Introduction to Go language
Introduction to Go languageIntroduction to Go language
Introduction to Go language
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
C++ vs python the best ever comparison
C++ vs python the best ever comparison C++ vs python the best ever comparison
C++ vs python the best ever comparison
 
C# and the Evolution of a Programming Language
C# and the Evolution of a Programming LanguageC# and the Evolution of a Programming Language
C# and the Evolution of a Programming Language
 

Destacado

C programming tutorial
C programming tutorialC programming tutorial
C programming tutorialMohit Saini
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement_jenica
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshareGagan Deep
 
Selection statements
Selection statementsSelection statements
Selection statementsHarsh Dabas
 
Break and continue statement in C
Break and continue statement in CBreak and continue statement in C
Break and continue statement in CInnovative
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C LanguageShaina Arora
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareGagan Deep
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controlsvinay arora
 
Loops Basics
Loops BasicsLoops Basics
Loops BasicsMushiii
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in CJeya Lakshmi
 

Destacado (20)

C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
 
C
CC
C
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
Break and continue
Break and continueBreak and continue
Break and continue
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
 
Selection statements
Selection statementsSelection statements
Selection statements
 
Break and continue statement in C
Break and continue statement in CBreak and continue statement in C
Break and continue statement in C
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Ch3 selection
Ch3 selectionCh3 selection
Ch3 selection
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
Loops
LoopsLoops
Loops
 
Ch3 repetition
Ch3 repetitionCh3 repetition
Ch3 repetition
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
 
Loops
LoopsLoops
Loops
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 

Similar a C Lecture

Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...bhargavi804095
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docMayurWagh46
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJmeharikiros2
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...bhargavi804095
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifestohu hans
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experimentAmos Wenger
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experimentAmos Wenger
 
Introduction
IntroductionIntroduction
IntroductionKamran
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c languagefarishah
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageRai University
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c languageRai University
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageRai University
 
introduction to c language
 introduction to c language introduction to c language
introduction to c languageRai University
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageRai University
 

Similar a C Lecture (20)

Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
 
C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...C++ helps you to format the I/O operations like determining the number of dig...
C++ helps you to format the I/O operations like determining the number of dig...
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
Introduction
IntroductionIntroduction
Introduction
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
 
Srgoc dotnet_new
Srgoc dotnet_newSrgoc dotnet_new
Srgoc dotnet_new
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c language
 

Más de Sudharsan S (20)

Xml1111
Xml1111Xml1111
Xml1111
 
Xml11
Xml11Xml11
Xml11
 
Xml plymouth
Xml plymouthXml plymouth
Xml plymouth
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
 
XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
 
Xml
XmlXml
Xml
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Unix
UnixUnix
Unix
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Unix
UnixUnix
Unix
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
C Introduction
C IntroductionC Introduction
C Introduction
 
College1
College1College1
College1
 
C Programming
C ProgrammingC Programming
C Programming
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
Preface
PrefacePreface
Preface
 
Toc Sg
Toc SgToc Sg
Toc Sg
 
Les08
Les08Les08
Les08
 
Les06
Les06Les06
Les06
 

Último

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 

Último (20)

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

C Lecture

  • 2. A little history:  1970’s  Unix  C, from BCPL (Thompson and Ritchie)  C programming Language  Widely used like the others: Fortran, Pascal  Main form of language for system programming  Available on any machine with C compiler and library
  • 3. Some Characteristics:  Scope:  Intended:  HPC, OS, general programming  Typically, long developing cycle  very platform dependent  Not intended: web, scripting, data processing  Features:  Close interaction with system  Standard library (user-level only),  no other fancy stuff: networking, memory, graphics  Extensive use of pointers  Procedure (OOB) programming, strictly pass by value
  • 4. Sample 1: /* Hello World! */ #include <stdio.h> int main() { printf(“Hello World!n”); return 0; }
  • 5. Walk through:  C program: hello.c  emacs, vi, vim, pico, joe …  But text editors only. No word processor  Preprocessing: hello.s, assembly code  cc -S hello.c  Compilation: hello.o, a binary file  cc -c hello.s  Linking: a.out or hello, an executable file  cc hello.o  cc -o hello hello.o  Loading (dynamical linking) and execution: ./hello  ./a.out  ./hello
  • 6. Programming (Editing)  C program: hello.c  emacs, vi, vim, pico, joe …  But text editors only. No word processor
  • 7. Compile:  Preprocessing: hello.s, assembly code  cc -S hello.c  Can you take a look at hello.s and compare to hello.c?  Compilation: hello.o, a binary file  cc -c hello.s  Do you know how to take a look at hello.o?  Linking: a.out or hello, an executable file  cc hello.o  cc -o hello hello.o  Want to look at the executable, hello?
  • 8. Run:  Loading (dynamical linking) and execute: ./hello  ./a.out  ./hello  What you do with java programs?  What computer does to run your program?
  • 9. Sample 1 Dissection:  What it has?  A function definition: main  A line of comment  A line of preprocessor directive  An output statement  A return clause  What it does?  Ask the computer to say hello to the world.  What it does not do?  It seems not computing!!  No real work  not taking input  does not change any value
  • 10. Sample 2: #include <stdio.h> #define MAGIC 10 int main(void) { int i, fact, quotient; while (i++ < 3) { printf(”Guess a factor of MAGIC larger than 1: "); scanf("%d”, &fact); quotient = MAGIC % fact; if (0 == quotient) printf(”You got it!n”); else printf(”Sorry, You missed it!n”); } return 0; }
  • 11. Sample 2 Dissection:  What more it has?  Macro definition  Variable declaration  Operations represented by operators  Conditional computation  Input Processing  Loops: three chances
  • 12. Syntax Dissection:  What is syntax?  m-w.com:  the way in which linguistic elements (as words) are put together to form constituents (as phrases or clauses)  How to put your C elements together into a program?  Variable declaration,  Identifier: case, keywords, style  datatype specification  char, short, int, long, float, double  Operators:  +, -, *, /, %, ++, --; >, <, ==, ; &, |, …  Priority and Precedence  Associativity
  • 13. More Syntax Dissection:  Preprocessor directive  macro  header file inclusion  Loop constructs  for, while, do-while, break, continue, label--go;  Conditional statements  If, else, else if, switch, break  Function definition  return type, parameter definition, parameter passing  Standard library and function calls  Take home practice:  Walk through the following steps with sample 2  preprocessing, compilation, linking, loading/execute  Modify and repeat once more if you can

Notas del editor

  1. My bias: C is hard and it is fun it embodies the most engineering art of programming