SlideShare a Scribd company logo
Course:

Programming Fundamentals
4.00 Credit Hours, Fall 2013,
Undergraduate Program
Instructor: Maryam Ehsan
SESSION 1, 2

© www.uogsialkot.edu
What is computer?


Computer






Computer programs




A device capable of performing computations and making logical
decisions
A machine that manipulates data according to a list of instructions.
A programmable device that can store, retrieve, and process data.

Sets of instructions that control a computer’s processing of data

Hardware



Physical part of the computer
Various devices comprising a computer




Examples: keyboard, screen, mouse, disks, memory, CD-ROM, and
processing units

Software



A collection of computer programs, procedures and documentation that
perform some tasks on a computer system
Programs that run a computer
Programming Fundamentals by Maryam
Ehsan

2
Computer organization


There are Six logical units in every computer:


Input unit




Output unit




Performs arithmetic calculations and logic decisions

Central processing unit (CPU)




Rapid access, low capacity, stores input information

Arithmetic and logic unit (ALU)




Outputs information to output device (screen, printer) or to control
other devices.

Memory unit




Obtains information (data and computer programs) from input
devices (keyboard, mouse)

Supervises and coordinates the other sections of the computer

Secondary storage unit


Cheap, long-term, high-capacity storage, stores inactive programs
Programming Fundamentals by Maryam
Ehsan

3
Computer languages


Computer languages are divided into three types.
 Machine languages




Machine language is machine dependent.
Strings of numbers giving machine specific instructions
Example:
+1300042774
+1400593419
+1200274027



Assembly languages




English-like abbreviations representing elementary computer
operations (translated via assemblers)
Example:

LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Translator programs called assembler were developed to convert assembly
language programs to machine language programs at computer speed.
Programming Fundamentals by Maryam
Ehsan

4
Computer languages


High-level languages
 Similar to everyday English, use mathematical notations
(translated via compilers)
 Example:
grossPay = basePay + overTimePay










C, C++ are the most widely used high level languages. Some
other examples are
FORTRAN (formula translator)
Used in scientific and engineering applications
COBOL (common business oriented language)
Used to manipulate large amounts of data
Pascal
Used to teach structured programming
Translator programs called Compilers converts high-level
language programs Programming Fundamentals language
into machine by Maryam
5
Ehsan
Basics of a typical C environment



Phases of C Programs
to be executed

Edit

Preprocess

Compile

Link

Load

Execute

Editor

Disk

Program is created in
the editor and stored
on disk.

Preprocessor

Disk

Preprocessor program
processes the code.

Compiler

Disk

Compiler creates
object code and stores
it on disk.

Disk

Linker links the object
code with the libraries,
creates a.exe and
stores it on disk

Linker

Primary
Memory

Loader
Loader puts program
in memory.

Disk

.
.
.
.
.
.

Primary
Memory

CPU

 

Programming Fundamentals by Maryam
Ehsan

.
.
.
.
.
.

CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
6
executes.
Program organization


Program statement






Definition
Declaration
Action

Executable unit



Named set of program statements
Different languages refer to executable units by different names
 Subroutine: Fortran and Basic
 Procedure: Pascal
 Function : C,C++

Programming Fundamentals by Maryam
Ehsan

7
C programming


C program





Collection of definitions, declarations and functions
Collection can span multiple files

2 Steps to Learn C



Write a program in C
Use Functions of C(Standard Template Libraries)

Programming Fundamentals by Maryam
Ehsan

8
C Programming
Simple program to print a line of text.

1

// A first program in C

2

Comments
return is a way to exit a function 
#include <stdio.h>
from a function.
Written between /* and  */ or following a //.
preprocessor directive

3
4
5
6
7

return 0, in this case, means that 
Improve program readability and do not cause the 
Message to the C preprocessor.
the program terminated normally. It  
computer to perform any action.
int main()
is one of the several means used to  Lines beginning with # are preprocessor directives.
exit a function
{
#include <stdio.h> tells the preprocessor to 
The left brace ,{, line 5 must begin the body of 
include the contents of the file <stdio>, which 
cout << "Welcome to C!n";
function and the corresponding right brace ,}, line 
includes input/output operations (such as printing 
9 must end the body of each function.
to the screen).
C programs contain one or more functions, one of 

8
9

return 0;
}

// indicate that program ended successfully
which must be main

Prints the string of characters contained between the quotation marks. 
Parenthesis are used to indicate a function
int means that main "returns" an integer value.  
Programming Fundamentals by Maryam
Ehsan

9
C Programming


Printf()



Standard output stream object
“Connected” to the screen

Programming Fundamentals by Maryam
Ehsan

10
C Programming
1 // an example to observe using statement
2 // program to display greeting
3 #include <stdio.h>
4
5 int main()
6 {
7

printf( “Hello world“);

8
9

return 0;

// indicate that program ended successfully

10 }
Programming Fundamentals by Maryam
Ehsan

11
Escape Character


Indicates that a “special” character is to be output
Escape Sequence

Description

n

Newline. Position the screen cursor to the
beginning of the next line.

t

Horizontal tab. Move the screen cursor to the
next tab stop.

r

Carriage return. Position the screen cursor to the
beginning of the current line; do not advance to
the next line.

a

Alert. Sound the system bell.



Backslash. Used to print a backslash character.

"

Double quote. Used to print a double quote character.
Programming Fundamentals by Maryam
Ehsan

12
C Programming


There are multiple ways to print text. Following are some more examples.
1

//observing the use of n

2

// Printing a line with multiple statements

3

#include <stdio.h>

4
5

int main()

6

{

7

cout << "Welcome ";

8

cout << "to C!n";

9
10

return 0;

// indicate that program ended successfully

11 }

The output would be as bellow
Welcome to C!
Unless new line 'n' is specified, the text continues
on the same line.

Programming Fundamentals by Maryam
Ehsan

13
C Programming
1

// printing multiple lines with a single statement

2

// Printing multiple lines with a single statement

3

#include <stdio.h>

4
5

int main()

6

{

7

printf("WelcomentonnC!n“);

8
9

return 0;

// indicate that program ended successfully

10 }

Welcome
To
C!

Multiple lines can be printed with one
statement.

Programming Fundamentals by Maryam
Ehsan

14
Testing and Debugging


Bug




A mistake in a program

Debugging


Eliminating mistakes in programs

Programming Fundamentals by Maryam
Ehsan

15
Program Errors


Syntax errors



Violation of the grammar rules of the language
Discovered by the compiler




Run-time errors




Error messages may not always show correct location of
errors

Error conditions detected by the computer at run-time

Logic errors




Errors in the program’s algorithm
Most difficult to diagnose
Computer does not recognize an error

Programming Fundamentals by Maryam
Ehsan

16
END
 Thank you


Programming Fundamentals by Maryam
Ehsan

17

More Related Content

What's hot

computer languages
computer languagescomputer languages
computer languages
The millennium school
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
raksharao
 
High Level Language (HLL)
High Level Language (HLL)High Level Language (HLL)
High Level Language (HLL)
Maliha Jahan
 
Computer language
Computer languageComputer language
Computer language
Mazharul Sabbir
 
High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language
adnan usmani
 
introduction computer programming languages
introduction computer programming languages introduction computer programming languages
introduction computer programming languages
BakhatAli3
 
Programming languages
Programming languagesProgramming languages
Programming languages
Archana Maharjan
 
Presentation on computer language
Presentation on computer languagePresentation on computer language
Presentation on computer language
Swarnima Tiwari
 
classification of computer language
classification of computer languageclassification of computer language
classification of computer language
BinamraRegmi
 
Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming Languages
Juhi Bhoyar
 
Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...
SHUBHAM PATIDAR FISHERIES ADDAA
 
Computer Languages.
Computer Languages.Computer Languages.
Computer Languages.
Aditya Sheoran
 
Classification of Programming Languages
Classification of Programming LanguagesClassification of Programming Languages
Classification of Programming Languages
Project Student
 
Computer Language
Computer LanguageComputer Language
Computer Language
Deepak Yadav
 
Computer Languages....ppt
Computer Languages....pptComputer Languages....ppt
Computer Languages....ppthashgeneration
 
Computer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clComputer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clSaumya Sahu
 
What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.
Questpond
 
Development of computer languages
Development of computer languagesDevelopment of computer languages
Development of computer languages
luckas chauhan
 

What's hot (20)

computer languages
computer languagescomputer languages
computer languages
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
 
High Level Language (HLL)
High Level Language (HLL)High Level Language (HLL)
High Level Language (HLL)
 
Computer language
Computer languageComputer language
Computer language
 
High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language
 
Computer languages 11
Computer languages 11Computer languages 11
Computer languages 11
 
introduction computer programming languages
introduction computer programming languages introduction computer programming languages
introduction computer programming languages
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Presentation on computer language
Presentation on computer languagePresentation on computer language
Presentation on computer language
 
classification of computer language
classification of computer languageclassification of computer language
classification of computer language
 
Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming Languages
 
Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...Features of machine language, assembly language, high level language & their ...
Features of machine language, assembly language, high level language & their ...
 
Computer Languages.
Computer Languages.Computer Languages.
Computer Languages.
 
Classification of Programming Languages
Classification of Programming LanguagesClassification of Programming Languages
Classification of Programming Languages
 
Computer Language
Computer LanguageComputer Language
Computer Language
 
Computer Languages....ppt
Computer Languages....pptComputer Languages....ppt
Computer Languages....ppt
 
Computer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clComputer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 cl
 
What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.What is Higher Language and Lower Language in programming.
What is Higher Language and Lower Language in programming.
 
Development of computer languages
Development of computer languagesDevelopment of computer languages
Development of computer languages
 
Introduction to programming languages
Introduction to programming languagesIntroduction to programming languages
Introduction to programming languages
 

Similar to Lecture1

Lecture01
Lecture01Lecture01
Lecture01
Xafran
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
gaafergoda
 
Introduction To Computer and Java
Introduction To Computer and JavaIntroduction To Computer and Java
Introduction To Computer and Java
PRN USM
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!manishamorya
 
Ch02.pdf
Ch02.pdfCh02.pdf
Ch02.pdf
Test835033
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptx
HazardRhenz1
 
Software Concepts Notes
Software Concepts NotesSoftware Concepts Notes
Software Concepts Notes
Prof. Dr. K. Adisesha
 
C intro
C introC intro
C intro
Mohit Patodia
 
Big Java Chapter 1
Big Java Chapter 1Big Java Chapter 1
Big Java Chapter 1
Maria Joslin
 
L2 ch1
L2  ch1L2  ch1
L2 ch1
Taqsim Rajon
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
farishah
 
Whole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThWhole c++ lectures ITM1 Th
Whole c++ lectures ITM1 Th
Aram Mohammed
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
Abdalla536859
 
Introduction
IntroductionIntroduction
Introduction
Kamran
 
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdfConcisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
feelinggift
 
Vskills c developer sample material
Vskills c developer sample materialVskills c developer sample material
Vskills c developer sample material
Vskills
 

Similar to Lecture1 (20)

Lecture01
Lecture01Lecture01
Lecture01
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
Introduction To Computer and Java
Introduction To Computer and JavaIntroduction To Computer and Java
Introduction To Computer and Java
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
CISY 105 Chapter 1
CISY 105 Chapter 1CISY 105 Chapter 1
CISY 105 Chapter 1
 
Ch02.pdf
Ch02.pdfCh02.pdf
Ch02.pdf
 
introductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptxintroductiontocomputerprogramming.pptx
introductiontocomputerprogramming.pptx
 
Software Concepts Notes
Software Concepts NotesSoftware Concepts Notes
Software Concepts Notes
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
C intro
C introC intro
C intro
 
Big Java Chapter 1
Big Java Chapter 1Big Java Chapter 1
Big Java Chapter 1
 
C programming part1
C programming part1C programming part1
C programming part1
 
L2 ch1
L2  ch1L2  ch1
L2 ch1
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
Whole c++ lectures ITM1 Th
Whole c++ lectures ITM1 ThWhole c++ lectures ITM1 Th
Whole c++ lectures ITM1 Th
 
Chapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptxChapter 1 Introduction to C .pptx
Chapter 1 Introduction to C .pptx
 
Introduction
IntroductionIntroduction
Introduction
 
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdfConcisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
 
Book ppt
Book pptBook ppt
Book ppt
 
Vskills c developer sample material
Vskills c developer sample materialVskills c developer sample material
Vskills c developer sample material
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 

Lecture1

  • 1. Course: Programming Fundamentals 4.00 Credit Hours, Fall 2013, Undergraduate Program Instructor: Maryam Ehsan SESSION 1, 2 © www.uogsialkot.edu
  • 2. What is computer?  Computer     Computer programs   A device capable of performing computations and making logical decisions A machine that manipulates data according to a list of instructions. A programmable device that can store, retrieve, and process data. Sets of instructions that control a computer’s processing of data Hardware   Physical part of the computer Various devices comprising a computer   Examples: keyboard, screen, mouse, disks, memory, CD-ROM, and processing units Software   A collection of computer programs, procedures and documentation that perform some tasks on a computer system Programs that run a computer Programming Fundamentals by Maryam Ehsan 2
  • 3. Computer organization  There are Six logical units in every computer:  Input unit   Output unit   Performs arithmetic calculations and logic decisions Central processing unit (CPU)   Rapid access, low capacity, stores input information Arithmetic and logic unit (ALU)   Outputs information to output device (screen, printer) or to control other devices. Memory unit   Obtains information (data and computer programs) from input devices (keyboard, mouse) Supervises and coordinates the other sections of the computer Secondary storage unit  Cheap, long-term, high-capacity storage, stores inactive programs Programming Fundamentals by Maryam Ehsan 3
  • 4. Computer languages  Computer languages are divided into three types.  Machine languages    Machine language is machine dependent. Strings of numbers giving machine specific instructions Example: +1300042774 +1400593419 +1200274027  Assembly languages   English-like abbreviations representing elementary computer operations (translated via assemblers) Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY Translator programs called assembler were developed to convert assembly language programs to machine language programs at computer speed. Programming Fundamentals by Maryam Ehsan 4
  • 5. Computer languages  High-level languages  Similar to everyday English, use mathematical notations (translated via compilers)  Example: grossPay = basePay + overTimePay      C, C++ are the most widely used high level languages. Some other examples are FORTRAN (formula translator) Used in scientific and engineering applications COBOL (common business oriented language) Used to manipulate large amounts of data Pascal Used to teach structured programming Translator programs called Compilers converts high-level language programs Programming Fundamentals language into machine by Maryam 5 Ehsan
  • 6. Basics of a typical C environment  Phases of C Programs to be executed  Edit  Preprocess  Compile  Link  Load  Execute Editor Disk Program is created in the editor and stored on disk. Preprocessor Disk Preprocessor program processes the code. Compiler Disk Compiler creates object code and stores it on disk. Disk Linker links the object code with the libraries, creates a.exe and stores it on disk Linker Primary Memory Loader Loader puts program in memory. Disk . . . . . . Primary Memory CPU   Programming Fundamentals by Maryam Ehsan . . . . . . CPU takes each instruction and executes it, possibly storing new data values as the program 6 executes.
  • 7. Program organization  Program statement     Definition Declaration Action Executable unit   Named set of program statements Different languages refer to executable units by different names  Subroutine: Fortran and Basic  Procedure: Pascal  Function : C,C++ Programming Fundamentals by Maryam Ehsan 7
  • 8. C programming  C program    Collection of definitions, declarations and functions Collection can span multiple files 2 Steps to Learn C   Write a program in C Use Functions of C(Standard Template Libraries) Programming Fundamentals by Maryam Ehsan 8
  • 9. C Programming Simple program to print a line of text. 1 // A first program in C 2 Comments return is a way to exit a function  #include <stdio.h> from a function. Written between /* and  */ or following a //. preprocessor directive 3 4 5 6 7 return 0, in this case, means that  Improve program readability and do not cause the  Message to the C preprocessor. the program terminated normally. It   computer to perform any action. int main() is one of the several means used to  Lines beginning with # are preprocessor directives. exit a function { #include <stdio.h> tells the preprocessor to  The left brace ,{, line 5 must begin the body of  include the contents of the file <stdio>, which  cout << "Welcome to C!n"; function and the corresponding right brace ,}, line  includes input/output operations (such as printing  9 must end the body of each function. to the screen). C programs contain one or more functions, one of  8 9 return 0; } // indicate that program ended successfully which must be main Prints the string of characters contained between the quotation marks.  Parenthesis are used to indicate a function int means that main "returns" an integer value.   Programming Fundamentals by Maryam Ehsan 9
  • 10. C Programming  Printf()   Standard output stream object “Connected” to the screen Programming Fundamentals by Maryam Ehsan 10
  • 11. C Programming 1 // an example to observe using statement 2 // program to display greeting 3 #include <stdio.h> 4 5 int main() 6 { 7 printf( “Hello world“); 8 9 return 0; // indicate that program ended successfully 10 } Programming Fundamentals by Maryam Ehsan 11
  • 12. Escape Character  Indicates that a “special” character is to be output Escape Sequence Description n Newline. Position the screen cursor to the beginning of the next line. t Horizontal tab. Move the screen cursor to the next tab stop. r Carriage return. Position the screen cursor to the beginning of the current line; do not advance to the next line. a Alert. Sound the system bell. Backslash. Used to print a backslash character. " Double quote. Used to print a double quote character. Programming Fundamentals by Maryam Ehsan 12
  • 13. C Programming  There are multiple ways to print text. Following are some more examples. 1 //observing the use of n 2 // Printing a line with multiple statements 3 #include <stdio.h> 4 5 int main() 6 { 7 cout << "Welcome "; 8 cout << "to C!n"; 9 10 return 0; // indicate that program ended successfully 11 } The output would be as bellow Welcome to C! Unless new line 'n' is specified, the text continues on the same line. Programming Fundamentals by Maryam Ehsan 13
  • 14. C Programming 1 // printing multiple lines with a single statement 2 // Printing multiple lines with a single statement 3 #include <stdio.h> 4 5 int main() 6 { 7 printf("WelcomentonnC!n“); 8 9 return 0; // indicate that program ended successfully 10 } Welcome To C! Multiple lines can be printed with one statement. Programming Fundamentals by Maryam Ehsan 14
  • 15. Testing and Debugging  Bug   A mistake in a program Debugging  Eliminating mistakes in programs Programming Fundamentals by Maryam Ehsan 15
  • 16. Program Errors  Syntax errors   Violation of the grammar rules of the language Discovered by the compiler   Run-time errors   Error messages may not always show correct location of errors Error conditions detected by the computer at run-time Logic errors    Errors in the program’s algorithm Most difficult to diagnose Computer does not recognize an error Programming Fundamentals by Maryam Ehsan 16
  • 17. END  Thank you  Programming Fundamentals by Maryam Ehsan 17