SlideShare uma empresa Scribd logo
1 de 31
Computer Programming
Learning Objectives 
•First course in Computer Science 
– No previous knowledge is assumed ! 
•By the end of the course, students will: 
– Understand fundamental concepts of 
computer programming/imperative structured 
programming languages 
– Design algorithms to solve (simple) problems 
– Use the C programming language
Fundamentals – Chapter outline: 
• Classical model for computing machines 
• Programming 
• Programming languages 
• Compiling 
• Operating system 
Setting the basic 
concepts and 
terminology …
Model of a computing machine 
• Computing machine (Computer): “a machine 
that stores and manipulates information under 
the control of a changeable program that is 
stored in its memory.” 
– Pocket calculator: not a computer ! Manipulates information, but 
is built to do a specific task (no changeable stored program) 
• This model is named the “von Neumann architecture” (John von 
Neumann – 1945; EDVAC - Electronic Discrete Variable Automatic 
Computer – the first stored-program computer) 
• Stored-program concept: earlier ideas in theoretical articles of: Alan 
Turing (1936), Konrad Zuse (1936)
The von Neumann architecture 
CPU 
Input Device Output Device 
ALU CU 
Main memory 
(RAM) 
Secondary 
storage
The von Neumann architecture 
• Central Processing Unit (CPU): the “brain” of the machine. 
– CU: Control Unit 
– ALU: Arithmetic and Logic Unit 
• Carries out all basic operations of the computer 
• Examples of basic operation: adding two numbers, testing to see if two 
numbers are equal. 
• Main memory (called RAM for Random Access Memory): stores 
programs and data 
– Fast but volatile 
• Secondary memory: provides permanent storage 
• Human-computer interaction: through input and output devices. 
– keyboard, mouse, monitor 
– Information from input devices is processed by the CPU and may be 
sent to the main or secondary memory. When information needs to be 
displayed, the CPU sends it to the output device(s).
How it works 
• How does a computer execute a program ? (example 
programs: a computer game, a word processor, etc) 
• the instructions that comprise the program are copied 
from the permanent secondary memory into the main 
memory 
• After the instructions are loaded, the CPU starts 
executing the program. 
• For each instruction, the instruction is retrieved from 
memory, decoded to figure out what it represents, and 
the appropriate action carried out. (the fetch- execute 
cycle) 
• Then the next instruction is fetched, decoded and 
executed.
Machine level programming 
• Example: suppose we want the computer to add 
two numbers, and if the preliminary result is less 
than 10, then add 10 to the result 
• The instructions that the CPU carries out might be : 
[INSTR1] Load into ALU the number from mem location 15 
[INSTR2] Load into ALU the number from mem location 7 
[INSTR3] Add the two numbers in the ALU 
[INSTR4] If result is bigger than 10 jump to [INSTR6] 
[INSTR5] Add 10 to the number in the ALU 
[INSTR6] Store the result from ALU into mem location 3 
• The processors instruction set: all basic operations that 
can be carried out by a certain type of processor
Machine level programming 
• the instructions and operands are represented in binary notation 
(sequences of 0s and 1s). 
– Why binary ? Because computer hardware relies on electric/electronic 
circuits that have/can switch between 2 states 
– bit (binary digit) 
– Byte: 8 bits 
• The program carried out by the CPU, on a hypothetical processor 
type, could be: 
1010 1111 
1011 0111 
0111 
… 
• This way had to be programmed the first computers ! 
• The job of the first programmers was to code directly in machine 
language and to enter their programs using switches
Example: old computer frontpanel 
LEDS display the current 
memory address and 
contents of current memory 
location or registers 
SWITCHES allow programmer to 
enter binary data / instructions
Higher level languages 
• Assembly language 
– First step from machine language 
– Uses symbolic names for operations 
– Example: a hypothetical assembly language program 
sequence: 
1010 1111 LD1 15 
1011 0111 LD2 7 
0111 ADD 
0011 1010 CMP 10 
0010 1100 JGE 12 
0110 1010 ADD 10 
… …
• Assembly language (cont) 
– Translation of assembly language into machine 
language: in the beginning done manually, later done 
by a special computer program – the assembler 
– Disadvantages: Low-level language: 
• programmer must learn the instruction set of the particular 
processor 
• Program must be rewritten in order to run on a different 
processor type – program is not portable
Higher level languages 
• High level languages 
– Using more abstract instructions 
– Portable programs result 
– Example: a hypothetical program sequence: 
DEFVAR a,b,c; 
BEGIN 
READ a 
READ b 
READ c 
c := a+b 
IF (c <10) THEN c:=c+10 
PRINT c 
END …
• High level languages 
– Writing portable programs, using more abstract 
instructions 
– A high level instruction (statement) is translated into 
many machine instructions 
– Translation of high level language into machine 
instructions: done by special computer programs – 
compilers or interpreters
Compilers/Interpreters 
Compiler 
Source 
Code 
Machine 
Code 
Executable 
Program 
Input 
data 
Output 
data 
Interpreter 
Source 
Code 
Input 
data 
Output 
data 
Compiler: analyzes program and 
translates it into machine language 
Executable program: can be run 
independently from compiler as 
many times => fast execution 
Interpreter: analyzes and executes 
program statements at the same 
time 
Execution is slower 
Easier to debug program
Operating Systems 
• Operating system: a program that controls the 
entire operation of a computer system: 
– Handles all input and output (I/O) operations that are 
performed on a computer 
– manages the computer system’s resources 
– handles the execution of programs (including 
multitasking or multiuser facilities) 
• Most famous OS families: 
– Windows 
– Unix
Higher Level Languages 
• Programming Paradigms: 
– Imperative Programming: describes the exact 
sequences of commands to be executed 
• Structured programming, procedural programming 
– FORTRAN, C, PASCAL, … 
• Object oriented programming 
– C++, Java, C#, … 
– Declarative programming: program describes what it 
should do, not how 
• Functional programming 
– Lisp, ML, … 
• Logic Programming 
– Prolog
The C Programming Language 
• Developed by Dennis Ritchie at AT&T Bell Laboratories 
in the early 1970s 
• Growth of C tightly coupled with growth of Unix: Unix 
was written mostly in C 
• Success of PCs: need of porting C on MS-DOS 
• Many providers of C compilers for many different 
platforms => need for standardization of the C language 
• 1990: ANSI C (American National Standards Institute) 
• International Standard Organization: ISO/IEC 9899:1990 
• 1999: standard updated: C99, or ISO/IEC 9899:1999
The first C program 
#include <stdio.h> 
int main (void) 
{ 
printf ("Programming is fun.n"); 
return 0; 
} 
uses standard library 
input and output functions 
(printf) 
the program 
begin of program 
statements 
end of program 
main: a special name that indicates where the program must begin execution. It is 
a special function. 
first statement: calls a routine named printf, with argument the string of characters 
“Programming is fun n” 
last statement: finishes execution of main and returns to the system a status value 
of 0 (conventional value for OK)
The format in C 
• Statements are terminated with semicolons 
• Indentation is nice to be used for increased readability. 
• Free format: white spaces and indentation is ignored by 
compiler 
• C is case sensitive – pay attention to lower and upper 
case letters when typing ! 
– All C keywords and standard functions are lower case 
– Typing INT, Int, etc instead of int is a compiler error 
• Strings are placed in double quotes 
• New line is represented by n (Escape sequence)
Compiling and running C programs 
Editor 
Compiler 
Linker 
Source code 
file.c 
Object code 
file.obj 
Executable code 
file.exe 
Libraries 
IDE (Integrated 
Development 
Environment)
C Compilers and IDE’s 
• One can: 
– use a text editor to edit source code, and then use independent 
command-line compilers and linkers 
– use an IDE: everything together + facilities to debug, develop 
and organize large projects 
• There are several C compilers and IDE’s that support 
various C compilers 
• Lab: Dev-C++ IDE for C and C++, Free Software (under 
the GNU General Public License) 
– Works with gcc (GNU C Compiler) 
• supports the C99 standard 
• available on Windows and Unix 
– The GNU Project (http://www.gnu.org/): launched in 1984 in 
order to develop a complete Unix-like operating system which is 
free software - the GNU system.
Debugging program errors 
Editor 
Compiler 
Linker 
Source code 
file.c 
Object code 
file.obj 
Executable code 
file.exe 
Syntactic 
Errors 
Libraries 
Semantic 
Errors
Syntax and Semantics 
• Syntax errors: violation of programming 
language rules (grammar) 
– "Me speak English good." 
– Use valid C symbols in wrong places 
– Detected by the compiler 
• Semantics errors: errors in meaning: 
– "This sentence is excellent Italian." 
– Programs are syntactically correct but don’t produce 
the expected output 
– User observes output of running program
Second program 
#include <stdio.h> 
int main (void) 
{ 
printf ("Programming is fun.n"); 
printf ("And programming in C is even more fun.n"); 
return 0; 
}
Displaying multiple lines of text 
#include <stdio.h> 
int main (void) 
{ 
printf ("Testing...n..1n...2n....3n"); 
return 0; 
} 
Output: 
Testing... 
..1 
...2 
....3 
It is not necessary 
to make a separate 
call to printf for each 
line of output !
Variables 
• Programs can use symbolic names for 
storing computation data and results 
• Variable: a symbolic name for a memory 
location 
– programmer doesn’t has to worry about 
specifying (or even knowing) the value of the 
location’s address 
• In C, variables have to be declared before 
they are used
Using and Displaying Variables 
#include <stdio.h> 
int main (void) 
{ 
int sum; 
sum = 50 + 25; 
printf ("The sum of 50 and 25 is %in", sum); 
return 0; 
} 
Variable sum declared of type int 
Variable sum assigned expression 50+25 
Value of variable sum is printed in place of %i 
The printf routine call has now 2 arguments: first argument a string containing also a 
format specifier (%i), that holds place for an integer value to be inserted here
Displaying multiple values 
#include <stdio.h> 
int main (void) 
{ 
int value1, value2, sum; 
value1 = 50; 
value2 = 25; 
sum = value1 + value2; 
printf ("The sum of %i and %i is %in",value1, value2, sum); 
return 0; 
} 
The format string must contain as many placeholders as expressions to be printed
Using comments in a program 
• Comment statements are used in a program to 
document it and to enhance its readability. 
• Useful for human readers of the program – compiler 
ignores comments 
• Ways to insert comments in C: 
– When comments span several lines: start marked with /*, end 
marked with */ 
– Comments at the end of a line: start marked with //
Using comments in a program 
/* This program adds two integer values 
and displays the results */ 
#include <stdio.h> 
int main (void) 
{ 
// Declare variables 
int value1, value2, sum; 
// Assign values and calculate their sum 
value1 = 50; 
value2 = 25; 
sum = value1 + value2; 
// Display the result 
printf ("The sum of %i and %i is %in", 
value1, value2, sum); 
return 0; 
}

Mais conteúdo relacionado

Mais procurados

Ch0 computer systems overview
Ch0 computer systems overviewCh0 computer systems overview
Ch0 computer systems overviewAboubakarIbrahima
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Bilal Amjad
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler languageAshok Raj
 
Computer Organization and Assembly Language
Computer Organization and Assembly LanguageComputer Organization and Assembly Language
Computer Organization and Assembly Languagefasihuddin90
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programminghimhk
 
C++ Training - Lecture 01
C++ Training - Lecture 01C++ Training - Lecture 01
C++ Training - Lecture 01Babak Farhang
 
An overview of computers and programming languages
An overview of computers and programming languages An overview of computers and programming languages
An overview of computers and programming languages Ahmad Idrees
 
INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1Mubarek Kurt
 
Chapt 01 Assembly Language
Chapt 01 Assembly LanguageChapt 01 Assembly Language
Chapt 01 Assembly LanguageHamza Akram
 
Assembly level language
Assembly level languageAssembly level language
Assembly level languagePDFSHARE
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterHossam Hassan
 
Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computerKirby Fabro
 

Mais procurados (20)

Ch0 computer systems overview
Ch0 computer systems overviewCh0 computer systems overview
Ch0 computer systems overview
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
 
[HK Roni] C Programming Lectures
[HK Roni] C Programming Lectures[HK Roni] C Programming Lectures
[HK Roni] C Programming Lectures
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler language
 
Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
 
Computer Organization and Assembly Language
Computer Organization and Assembly LanguageComputer Organization and Assembly Language
Computer Organization and Assembly Language
 
Assembly language programming
Assembly language programmingAssembly language programming
Assembly language programming
 
C++ Training - Lecture 01
C++ Training - Lecture 01C++ Training - Lecture 01
C++ Training - Lecture 01
 
An overview of computers and programming languages
An overview of computers and programming languages An overview of computers and programming languages
An overview of computers and programming languages
 
System software
System softwareSystem software
System software
 
INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1INTRODUCTION TO C++, Chapter 1
INTRODUCTION TO C++, Chapter 1
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Chapt 01 Assembly Language
Chapt 01 Assembly LanguageChapt 01 Assembly Language
Chapt 01 Assembly Language
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 
Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computer
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
E.s unit 6
E.s unit 6E.s unit 6
E.s unit 6
 

Destaque

Machine Learning in Computer Chess: Genetic Programming and KRK
Machine Learning in Computer Chess: Genetic Programming and KRKMachine Learning in Computer Chess: Genetic Programming and KRK
Machine Learning in Computer Chess: Genetic Programming and KRKbutest
 
Teaching of computer programming
Teaching of  computer programmingTeaching of  computer programming
Teaching of computer programmingmarpasha
 
Robotics-Based Learning in the Context of Computer Programming
Robotics-Based Learning in the Context of Computer ProgrammingRobotics-Based Learning in the Context of Computer Programming
Robotics-Based Learning in the Context of Computer ProgrammingJacob Storer
 
Utilizing Web-based programming learning environment in University teaching
Utilizing Web-based programming learning environment in University teachingUtilizing Web-based programming learning environment in University teaching
Utilizing Web-based programming learning environment in University teachingViope Solutions Ltd
 
Integration of visualization techniques and active learning strategy in learn...
Integration of visualization techniques and active learning strategy in learn...Integration of visualization techniques and active learning strategy in learn...
Integration of visualization techniques and active learning strategy in learn...Siti Rosminah Md Derus
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programmingjosernova
 
Computer programming
Computer programmingComputer programming
Computer programmingAraya Psk
 
Evolving Adaptive Framework
Evolving Adaptive FrameworkEvolving Adaptive Framework
Evolving Adaptive Frameworkigualproject
 
Intro to Computer Programming and Games Design
Intro to Computer Programming and Games DesignIntro to Computer Programming and Games Design
Intro to Computer Programming and Games DesignIan Simpson
 
A Review of Games Designed to Improve Computer Programming Competencies
A Review of Games Designed to Improve Computer Programming CompetenciesA Review of Games Designed to Improve Computer Programming Competencies
A Review of Games Designed to Improve Computer Programming CompetenciesAdilson Vahldick
 
Exploring circles by using computer programming
Exploring circles by using computer programmingExploring circles by using computer programming
Exploring circles by using computer programmingJerry Sommerville
 
[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...
[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...
[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...cfernandezmedina
 
Inspiring Kids to Code Using Scratch and Other Tools
Inspiring Kids to Code Using Scratch and Other ToolsInspiring Kids to Code Using Scratch and Other Tools
Inspiring Kids to Code Using Scratch and Other ToolsSt. Petersburg College
 
Computer Programming Overview
Computer Programming OverviewComputer Programming Overview
Computer Programming Overviewagorolabs
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming LanguageTahani Al-Manie
 
Lang generations 7557_syed_ghazanfarnaqvi_saturday
Lang generations 7557_syed_ghazanfarnaqvi_saturdayLang generations 7557_syed_ghazanfarnaqvi_saturday
Lang generations 7557_syed_ghazanfarnaqvi_saturdaySyed Naqvi
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0Aarti P
 

Destaque (20)

Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Machine Learning in Computer Chess: Genetic Programming and KRK
Machine Learning in Computer Chess: Genetic Programming and KRKMachine Learning in Computer Chess: Genetic Programming and KRK
Machine Learning in Computer Chess: Genetic Programming and KRK
 
Teaching of computer programming
Teaching of  computer programmingTeaching of  computer programming
Teaching of computer programming
 
Robotics-Based Learning in the Context of Computer Programming
Robotics-Based Learning in the Context of Computer ProgrammingRobotics-Based Learning in the Context of Computer Programming
Robotics-Based Learning in the Context of Computer Programming
 
Utilizing Web-based programming learning environment in University teaching
Utilizing Web-based programming learning environment in University teachingUtilizing Web-based programming learning environment in University teaching
Utilizing Web-based programming learning environment in University teaching
 
Integration of visualization techniques and active learning strategy in learn...
Integration of visualization techniques and active learning strategy in learn...Integration of visualization techniques and active learning strategy in learn...
Integration of visualization techniques and active learning strategy in learn...
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Computer programming
Computer programmingComputer programming
Computer programming
 
Evolving Adaptive Framework
Evolving Adaptive FrameworkEvolving Adaptive Framework
Evolving Adaptive Framework
 
Intro to Computer Programming and Games Design
Intro to Computer Programming and Games DesignIntro to Computer Programming and Games Design
Intro to Computer Programming and Games Design
 
A Review of Games Designed to Improve Computer Programming Competencies
A Review of Games Designed to Improve Computer Programming CompetenciesA Review of Games Designed to Improve Computer Programming Competencies
A Review of Games Designed to Improve Computer Programming Competencies
 
Exploring circles by using computer programming
Exploring circles by using computer programmingExploring circles by using computer programming
Exploring circles by using computer programming
 
[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...
[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...
[ITICSE 2013] COLMENA: Assistance in computer programming learning using educ...
 
Processing Language
Processing LanguageProcessing Language
Processing Language
 
Inspiring Kids to Code Using Scratch and Other Tools
Inspiring Kids to Code Using Scratch and Other ToolsInspiring Kids to Code Using Scratch and Other Tools
Inspiring Kids to Code Using Scratch and Other Tools
 
Computer Programming Overview
Computer Programming OverviewComputer Programming Overview
Computer Programming Overview
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
Lang generations 7557_syed_ghazanfarnaqvi_saturday
Lang generations 7557_syed_ghazanfarnaqvi_saturdayLang generations 7557_syed_ghazanfarnaqvi_saturday
Lang generations 7557_syed_ghazanfarnaqvi_saturday
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
Intro To Scratch
Intro To ScratchIntro To Scratch
Intro To Scratch
 

Semelhante a Synapseindia dot net development computer programming

Assembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly LangaugeAssembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly Langaugemustafkhalid
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptxgaafergoda
 
Chapter1-CS115.ppt
Chapter1-CS115.pptChapter1-CS115.ppt
Chapter1-CS115.pptTyseerArman
 
Introduction
IntroductionIntroduction
IntroductionKamran
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxHazardRhenz1
 
Whole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThWhole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThAram Mohammed
 
9781285852744 ppt ch01
9781285852744 ppt ch019781285852744 ppt ch01
9781285852744 ppt ch01Terry Yoast
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptxchouguleamruta24
 
9781285852751 ppt c++
9781285852751 ppt c++9781285852751 ppt c++
9781285852751 ppt c++umair khan
 
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 Translatorsimtiazalijoono
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptxPmarkNorcio
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxAbdalla536859
 
introduction to c language
 introduction to c language introduction to c language
introduction to c languageRai University
 
01 Computer Basics (Ch1.1).pptx
01 Computer Basics (Ch1.1).pptx01 Computer Basics (Ch1.1).pptx
01 Computer Basics (Ch1.1).pptxsarah380333
 

Semelhante a Synapseindia dot net development computer programming (20)

Assembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly LangaugeAssembly Langauge Assembly Langauge Assembly Langauge
Assembly Langauge Assembly Langauge Assembly Langauge
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
Chapter1-CS115.ppt
Chapter1-CS115.pptChapter1-CS115.ppt
Chapter1-CS115.ppt
 
Introduction
IntroductionIntroduction
Introduction
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptx
 
01CHAP_1.PPT
01CHAP_1.PPT01CHAP_1.PPT
01CHAP_1.PPT
 
Whole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThWhole c++ lectures ITM1 Th
Whole c++ lectures ITM1 Th
 
9781285852744 ppt ch01
9781285852744 ppt ch019781285852744 ppt ch01
9781285852744 ppt ch01
 
C intro
C introC intro
C intro
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
 
9781285852751 ppt c++
9781285852751 ppt c++9781285852751 ppt c++
9781285852751 ppt c++
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
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
 
Introduction_to_Programming.pptx
Introduction_to_Programming.pptxIntroduction_to_Programming.pptx
Introduction_to_Programming.pptx
 
Program Logic and Design
Program Logic and DesignProgram Logic and Design
Program Logic and Design
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
lec 1.pptx
lec 1.pptxlec 1.pptx
lec 1.pptx
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
01 Computer Basics (Ch1.1).pptx
01 Computer Basics (Ch1.1).pptx01 Computer Basics (Ch1.1).pptx
01 Computer Basics (Ch1.1).pptx
 

Mais de Synapseindiappsdevelopment

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapseindiappsdevelopment
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseindiappsdevelopment
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overviewSynapseindiappsdevelopment
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications developmentSynapseindiappsdevelopment
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security developmentSynapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseindiappsdevelopment
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseindiappsdevelopment
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseindiappsdevelopment
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseindiappsdevelopment
 

Mais de Synapseindiappsdevelopment (20)

Synapse india elance top in demand in it skills
Synapse india elance top in demand in it skillsSynapse india elance top in demand in it skills
Synapse india elance top in demand in it skills
 
SynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture moduleSynapseIndia dotnet web development architecture module
SynapseIndia dotnet web development architecture module
 
SynapseIndia dotnet module development part 1
SynapseIndia  dotnet module development part 1SynapseIndia  dotnet module development part 1
SynapseIndia dotnet module development part 1
 
SynapseIndia dotnet framework library
SynapseIndia  dotnet framework librarySynapseIndia  dotnet framework library
SynapseIndia dotnet framework library
 
SynapseIndia dotnet development platform overview
SynapseIndia  dotnet development platform overviewSynapseIndia  dotnet development platform overview
SynapseIndia dotnet development platform overview
 
SynapseIndia dotnet development framework
SynapseIndia  dotnet development frameworkSynapseIndia  dotnet development framework
SynapseIndia dotnet development framework
 
SynapseIndia dotnet web applications development
SynapseIndia  dotnet web applications developmentSynapseIndia  dotnet web applications development
SynapseIndia dotnet web applications development
 
SynapseIndia dotnet website security development
SynapseIndia  dotnet website security developmentSynapseIndia  dotnet website security development
SynapseIndia dotnet website security development
 
SynapseIndia mobile build apps management
SynapseIndia mobile build apps managementSynapseIndia mobile build apps management
SynapseIndia mobile build apps management
 
SynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architectureSynapseIndia mobile apps deployment framework internal architecture
SynapseIndia mobile apps deployment framework internal architecture
 
SynapseIndia java and .net development
SynapseIndia java and .net developmentSynapseIndia java and .net development
SynapseIndia java and .net development
 
SynapseIndia dotnet development panel control
SynapseIndia dotnet development panel controlSynapseIndia dotnet development panel control
SynapseIndia dotnet development panel control
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client library
 
SynapseIndia php web development
SynapseIndia php web developmentSynapseIndia php web development
SynapseIndia php web development
 
SynapseIndia mobile apps architecture
SynapseIndia mobile apps architectureSynapseIndia mobile apps architecture
SynapseIndia mobile apps architecture
 
SynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architectureSynapseIndia mobile apps deployment framework architecture
SynapseIndia mobile apps deployment framework architecture
 
SynapseIndia mobile apps
SynapseIndia mobile appsSynapseIndia mobile apps
SynapseIndia mobile apps
 
SynapseIndia dotnet development
SynapseIndia dotnet developmentSynapseIndia dotnet development
SynapseIndia dotnet development
 
SynapseIndia dotnet client library Development
SynapseIndia dotnet client library DevelopmentSynapseIndia dotnet client library Development
SynapseIndia dotnet client library Development
 
SynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically developmentSynapseIndia creating asp controls programatically development
SynapseIndia creating asp controls programatically development
 

Último

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Último (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Synapseindia dot net development computer programming

  • 2. Learning Objectives •First course in Computer Science – No previous knowledge is assumed ! •By the end of the course, students will: – Understand fundamental concepts of computer programming/imperative structured programming languages – Design algorithms to solve (simple) problems – Use the C programming language
  • 3. Fundamentals – Chapter outline: • Classical model for computing machines • Programming • Programming languages • Compiling • Operating system Setting the basic concepts and terminology …
  • 4. Model of a computing machine • Computing machine (Computer): “a machine that stores and manipulates information under the control of a changeable program that is stored in its memory.” – Pocket calculator: not a computer ! Manipulates information, but is built to do a specific task (no changeable stored program) • This model is named the “von Neumann architecture” (John von Neumann – 1945; EDVAC - Electronic Discrete Variable Automatic Computer – the first stored-program computer) • Stored-program concept: earlier ideas in theoretical articles of: Alan Turing (1936), Konrad Zuse (1936)
  • 5. The von Neumann architecture CPU Input Device Output Device ALU CU Main memory (RAM) Secondary storage
  • 6. The von Neumann architecture • Central Processing Unit (CPU): the “brain” of the machine. – CU: Control Unit – ALU: Arithmetic and Logic Unit • Carries out all basic operations of the computer • Examples of basic operation: adding two numbers, testing to see if two numbers are equal. • Main memory (called RAM for Random Access Memory): stores programs and data – Fast but volatile • Secondary memory: provides permanent storage • Human-computer interaction: through input and output devices. – keyboard, mouse, monitor – Information from input devices is processed by the CPU and may be sent to the main or secondary memory. When information needs to be displayed, the CPU sends it to the output device(s).
  • 7. How it works • How does a computer execute a program ? (example programs: a computer game, a word processor, etc) • the instructions that comprise the program are copied from the permanent secondary memory into the main memory • After the instructions are loaded, the CPU starts executing the program. • For each instruction, the instruction is retrieved from memory, decoded to figure out what it represents, and the appropriate action carried out. (the fetch- execute cycle) • Then the next instruction is fetched, decoded and executed.
  • 8. Machine level programming • Example: suppose we want the computer to add two numbers, and if the preliminary result is less than 10, then add 10 to the result • The instructions that the CPU carries out might be : [INSTR1] Load into ALU the number from mem location 15 [INSTR2] Load into ALU the number from mem location 7 [INSTR3] Add the two numbers in the ALU [INSTR4] If result is bigger than 10 jump to [INSTR6] [INSTR5] Add 10 to the number in the ALU [INSTR6] Store the result from ALU into mem location 3 • The processors instruction set: all basic operations that can be carried out by a certain type of processor
  • 9. Machine level programming • the instructions and operands are represented in binary notation (sequences of 0s and 1s). – Why binary ? Because computer hardware relies on electric/electronic circuits that have/can switch between 2 states – bit (binary digit) – Byte: 8 bits • The program carried out by the CPU, on a hypothetical processor type, could be: 1010 1111 1011 0111 0111 … • This way had to be programmed the first computers ! • The job of the first programmers was to code directly in machine language and to enter their programs using switches
  • 10. Example: old computer frontpanel LEDS display the current memory address and contents of current memory location or registers SWITCHES allow programmer to enter binary data / instructions
  • 11. Higher level languages • Assembly language – First step from machine language – Uses symbolic names for operations – Example: a hypothetical assembly language program sequence: 1010 1111 LD1 15 1011 0111 LD2 7 0111 ADD 0011 1010 CMP 10 0010 1100 JGE 12 0110 1010 ADD 10 … …
  • 12. • Assembly language (cont) – Translation of assembly language into machine language: in the beginning done manually, later done by a special computer program – the assembler – Disadvantages: Low-level language: • programmer must learn the instruction set of the particular processor • Program must be rewritten in order to run on a different processor type – program is not portable
  • 13. Higher level languages • High level languages – Using more abstract instructions – Portable programs result – Example: a hypothetical program sequence: DEFVAR a,b,c; BEGIN READ a READ b READ c c := a+b IF (c <10) THEN c:=c+10 PRINT c END …
  • 14. • High level languages – Writing portable programs, using more abstract instructions – A high level instruction (statement) is translated into many machine instructions – Translation of high level language into machine instructions: done by special computer programs – compilers or interpreters
  • 15. Compilers/Interpreters Compiler Source Code Machine Code Executable Program Input data Output data Interpreter Source Code Input data Output data Compiler: analyzes program and translates it into machine language Executable program: can be run independently from compiler as many times => fast execution Interpreter: analyzes and executes program statements at the same time Execution is slower Easier to debug program
  • 16. Operating Systems • Operating system: a program that controls the entire operation of a computer system: – Handles all input and output (I/O) operations that are performed on a computer – manages the computer system’s resources – handles the execution of programs (including multitasking or multiuser facilities) • Most famous OS families: – Windows – Unix
  • 17. Higher Level Languages • Programming Paradigms: – Imperative Programming: describes the exact sequences of commands to be executed • Structured programming, procedural programming – FORTRAN, C, PASCAL, … • Object oriented programming – C++, Java, C#, … – Declarative programming: program describes what it should do, not how • Functional programming – Lisp, ML, … • Logic Programming – Prolog
  • 18. The C Programming Language • Developed by Dennis Ritchie at AT&T Bell Laboratories in the early 1970s • Growth of C tightly coupled with growth of Unix: Unix was written mostly in C • Success of PCs: need of porting C on MS-DOS • Many providers of C compilers for many different platforms => need for standardization of the C language • 1990: ANSI C (American National Standards Institute) • International Standard Organization: ISO/IEC 9899:1990 • 1999: standard updated: C99, or ISO/IEC 9899:1999
  • 19. The first C program #include <stdio.h> int main (void) { printf ("Programming is fun.n"); return 0; } uses standard library input and output functions (printf) the program begin of program statements end of program main: a special name that indicates where the program must begin execution. It is a special function. first statement: calls a routine named printf, with argument the string of characters “Programming is fun n” last statement: finishes execution of main and returns to the system a status value of 0 (conventional value for OK)
  • 20. The format in C • Statements are terminated with semicolons • Indentation is nice to be used for increased readability. • Free format: white spaces and indentation is ignored by compiler • C is case sensitive – pay attention to lower and upper case letters when typing ! – All C keywords and standard functions are lower case – Typing INT, Int, etc instead of int is a compiler error • Strings are placed in double quotes • New line is represented by n (Escape sequence)
  • 21. Compiling and running C programs Editor Compiler Linker Source code file.c Object code file.obj Executable code file.exe Libraries IDE (Integrated Development Environment)
  • 22. C Compilers and IDE’s • One can: – use a text editor to edit source code, and then use independent command-line compilers and linkers – use an IDE: everything together + facilities to debug, develop and organize large projects • There are several C compilers and IDE’s that support various C compilers • Lab: Dev-C++ IDE for C and C++, Free Software (under the GNU General Public License) – Works with gcc (GNU C Compiler) • supports the C99 standard • available on Windows and Unix – The GNU Project (http://www.gnu.org/): launched in 1984 in order to develop a complete Unix-like operating system which is free software - the GNU system.
  • 23. Debugging program errors Editor Compiler Linker Source code file.c Object code file.obj Executable code file.exe Syntactic Errors Libraries Semantic Errors
  • 24. Syntax and Semantics • Syntax errors: violation of programming language rules (grammar) – "Me speak English good." – Use valid C symbols in wrong places – Detected by the compiler • Semantics errors: errors in meaning: – "This sentence is excellent Italian." – Programs are syntactically correct but don’t produce the expected output – User observes output of running program
  • 25. Second program #include <stdio.h> int main (void) { printf ("Programming is fun.n"); printf ("And programming in C is even more fun.n"); return 0; }
  • 26. Displaying multiple lines of text #include <stdio.h> int main (void) { printf ("Testing...n..1n...2n....3n"); return 0; } Output: Testing... ..1 ...2 ....3 It is not necessary to make a separate call to printf for each line of output !
  • 27. Variables • Programs can use symbolic names for storing computation data and results • Variable: a symbolic name for a memory location – programmer doesn’t has to worry about specifying (or even knowing) the value of the location’s address • In C, variables have to be declared before they are used
  • 28. Using and Displaying Variables #include <stdio.h> int main (void) { int sum; sum = 50 + 25; printf ("The sum of 50 and 25 is %in", sum); return 0; } Variable sum declared of type int Variable sum assigned expression 50+25 Value of variable sum is printed in place of %i The printf routine call has now 2 arguments: first argument a string containing also a format specifier (%i), that holds place for an integer value to be inserted here
  • 29. Displaying multiple values #include <stdio.h> int main (void) { int value1, value2, sum; value1 = 50; value2 = 25; sum = value1 + value2; printf ("The sum of %i and %i is %in",value1, value2, sum); return 0; } The format string must contain as many placeholders as expressions to be printed
  • 30. Using comments in a program • Comment statements are used in a program to document it and to enhance its readability. • Useful for human readers of the program – compiler ignores comments • Ways to insert comments in C: – When comments span several lines: start marked with /*, end marked with */ – Comments at the end of a line: start marked with //
  • 31. Using comments in a program /* This program adds two integer values and displays the results */ #include <stdio.h> int main (void) { // Declare variables int value1, value2, sum; // Assign values and calculate their sum value1 = 50; value2 = 25; sum = value1 + value2; // Display the result printf ("The sum of %i and %i is %in", value1, value2, sum); return 0; }