Escolar Documentos
Profissional Documentos
Cultura Documentos
Introduction to Programming
Objectives
Introduction to Programming
Introduction to Programming
• Programs are developed
to instruct computers to do
specific tasks, or solve
specific problems
• A finite set of instructions
that if followed
accomplishes a particular
task is called an algorithm
• Thus, programming is the
activity of communicating
algorithms to computers
Introduction to Programming
Program Development Process
Problem or Task
make list check it
Requirements List
design algorithm verify
Algorithm
code program verify
Program
Introduction to Programming
Typical Programming Environment
Program is encoded
in a text editor and Editor Source code
stored on a disk
Executable code is
created by the linker
by linking the object Linker Executable file
codes and stored on
disk
Introduction to Programming
Typical Programming Environment
Introduction to Programming
Typical Programming Environment
In A Nutshell
Introduction to Programming
The C Programming Language
• We will be learning
programming using the C
programming language
B
(Ken Thompson)
C
(Dennis Ritchie)
Introduction to Programming
ANSI C
Introduction to Programming
Sample C Program 1: Hello World
Source code: hello.c
/* This program will display “Hello World” */
#include <stdio.h>
int main()
{
printf(“Hello World!”);
return 0;
}
Output
Hello World!
Introduction to Programming
C Program Structure
preprocessor directives
Introduction to Programming
Preprocessor Directives
Introduction to Programming
Preprocessor Directive: #include
source
source
code
code
Preprocessor File
to be
File included
to be
included
Resulting file
Introduction to Programming
Header Files
Introduction to Programming
Main Function
Introduction to Programming
Program Statements
Introduction to Programming
Comments
...
printf( “ /* This is NOT a comment */ ” );
...
Introduction to Programming
Sample C Program 2:
Average of Two Numbers
/* Filename: average.c */
#include <stdio.h>
int main(void)
{
float num1, num2, average;
Introduction to Programming
Laboratory Exercise Overview
Introduction to Programming