0% found this document useful (0 votes)
46 views37 pages

Chapter 1. Introduction

The document outlines the syllabus and structure for a programming course focused on the C programming language, detailing chapters, assessments, and grading policies. It covers the software development method, including problem specification, analysis, algorithm design, implementation, testing, and maintenance. Additionally, it introduces the C programming language, its history, uses, and basic programming concepts such as variables, expressions, and input/output functions.

Uploaded by

binben21789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views37 pages

Chapter 1. Introduction

The document outlines the syllabus and structure for a programming course focused on the C programming language, detailing chapters, assessments, and grading policies. It covers the software development method, including problem specification, analysis, algorithm design, implementation, testing, and maintenance. Additionally, it introduces the C programming language, its history, uses, and basic programming concepts such as variables, expressions, and input/output functions.

Uploaded by

binben21789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

NATIONAL ECONOMICS UNIVERSITY

SCHOOL OF INFORMATION TECHNOLOGY AND DIGITAL ECONOMICS

PRINCIPLES OF PROGRAMMING
CHAPTER 1. INTRODUCTION
LECTURER

PHD. PHAM XUAN LAM


Head of Department of Information Technology
📞 0937 638 683
📩 lampx@neu.edu.vn
BOOKS

Problem Solving and Program


Design in C, (8th Edition)
Jeri R. Hanly, Elliot B. Koffman
SYLLABUS

¡ Chapter 1: Introduction (Week 1 - 2)


¡ Chapter 2: Fundamentals of the C Programming (Week 3)
¡ Chapter 3: Data types and Operations (Week 4)
¡ Chapter 4: Input and Output (Week 5)
¡ Chapter 5: Control Structure (Week 6 - 7)
¡ Chapter 6: Functions (Week 8)
¡ Midterm Examination (write code – Week 9)
¡ Chapter 7: Pointers (Week 10)
¡ Chapter 8: Structure and Union Types (Week 11)
¡ Midterm Examination (write code – Week 12)
¡ Chapter 9: Files (Week 13 - 14)
¡ Final Examination (quiz)
ASSESSMENT & GRADING POLICY

¡ Class attendance: students must attend at least 70% number of classes.


¡ Grade:
¡ Discussion in the class: 10% of the final grade
¡ Midterm exams: 40% of the final grade
¡ Final exam: 50% of the final grade
PUTTING IT ALL TOGETHER

¡ Announcements
¡ Syllabus
¡ Books
¡ Slides
¡ Assignments
THE SOFTWARE DEVELOPMENT METHOD

¡ 6 basic steps:
1. Specify the problem requirements
2. Analyze the problem
3. Design the algorithm to solve the problem
4. Implement the algorithm
5. Test and verify the completed program
6. Maintain and update the program
1. SPECIFYING THE PROBLEM REQUIREMENTS

¡ Define the problem


¡ Identify user requirements
¡ Identify functional / non-functional requirements
¡ Prioritize requirements
¡ Review and refine the requirements
2. ANALYZE THE PROBLEM

¡ Analyzing the problem involves identifying the problem:


1. Inputs, that is, the data you have to work with
2. Outputs, that is, the desired results
3. Any additional requirements or constraints on the solution.

Problem Inputs
Problem Output
quantity of apples purchased (in pounds)
total cost of apples (in dollars)
cost per pound of apples (in dollars per pound)

Total cost = Unit cost * Number of units

Total cost of apples = Cost per pound * Pounds of apples


3. DESIGN THE ALGORITHM TO SOLVE THE PROBLEM

¡ An algorithm is a finite sequence of well-defined instructions, typically used to


solve a class of specific problems or to perform a computation.
¡ Finiteness − Algorithms must terminate after a finite number of steps.
¡ Unambiguous − Algorithm should be clear and unambiguous.
¡ Input/Output − An algorithm should have well-defined input/output
¡ Effectiveness − An algorithm should not contain any unnecessary and redundant steps
¡ Independent − An algorithm should have step-by-step directions, which should be independent of
any programming code.

Algorithms + Data Structures = Programs


3. DESIGN THE ALGORITHM TO SOLVE THE PROBLEM (CONT)

¡ Expressing algorithms:
¡ Natural language
¡ Flow charts
¡ Pseudocode
¡ Actual programming languages

¡ Example algorithms:
¡ Heuristic Algorithm
¡ Recursive Algorithm
¡ Brute Force Algorithm
¡ ...
4. IMPLEMENTING THE ALGORITHM

¡ Convert each algorithm step into one or more statements in a programming


language.
¡ Programming is the process of creating a set of instructions that tell a computer
how to perform a task.
5. TEST AND VERIFY THE COMPLETED PROGRAM

¡ Testing and verifying the program requires


testing the completed program to verify that it
works as desired.
¡ Don’t rely on just one test case. Run the program
several times using different sets of data to make
sure that it works correctly for every situation
provided for in the algorithm.
6. MAINTAIN AND UPDATE THE PROGRAM

¡ Maintaining and updating the program involves modifying a


program to remove previously undetected errors and to keep
it up-to-date
¡ Follow accepted program style guidelines
¡ Use version control
¡ Test changes carerefully
C PROGRAMING LANGUAGE

¡ C is a high-level programming language


developed in1972 by Dennis Ritchie at AT&T
Bell Laboratories.
¡ C was developed to overcome the problems of
previous languages (B, BCPL)
¡ C has consistently ranked among the top languages
in the TIOBE index, a measure of the popularity of
programming languages.

1941-2011
PROGRAMING LANGUAGE

People: Computer:
“Hello!” 11010101010101000
Programming
language
PROGRAMING LANGUAGE (2)
PROGRAMING LANGUAGE (3)

#include <stdio.h>
Code
int main()
{
printf("Hello World\n");
return 0;
}

Machine Code
LEVELS OF PROGRAMMING LANGUAGES

¡ Programming languages can be broadly


classified into three categories:
¡ Machine Languages
¡ Assembly Languages
¡ High Level Languages

¡ A compiler translate statements


written in a high-level programming
language and turns them into a lower-
level programming language
TIMELINE OF C PROGRAMMING LANGUAGE

Year C Standard
1972 Birth
1978 K&R C
1983/1989 ANSI C and ISO C
1999 C99
2011 C11
2018 C18
USES OF C PROGAMMING LANGUAGE

¡ C is widely used for systems


programming in implementing operating
systems and embedded
system applications
¡ Compilers, libraries,
and interpreters of other high level
programming languages are often
written in C
¡ C can be used for website programming
using the Common Gateway
Interface (CGI)
PROCEDURE-ORIENTED PROGRAMMING LANGUAGE (POP)

¡ C is known as procedure-oriented programming (like PASCAL, COBOL .etc)


¡ POP basically contains group of instructions known as function. There are multiple
functions into the program.
OBJECT-ORIENTED PROGRAMMING (OOP)

¡ OOP is a programming paradigm based on the


concept of "objects", which can
contain Data and Code:
¡ Data: in the form of fields (often known
as attributes or properties),
¡ Code: in the form of procedures (often known
as methods).
PROGRAMING TOOLS

¡ Online Tools:
¡ www.onlinegdb.com/online_c_compiler
¡ https://www.tutorialspoint.com/compile_c_online.php
¡ ....

¡ Offline Tools:
¡ CodeBlocks
¡ DevC
¡ CLion
ONLINE TOOL

¡ https://www.onlinegdb.com/online_c_compiler
¡ http://www.codeblocks.org/downloads/binaries

Download and Install


WRITING OUR FIRST PROGRAM – HELLO WORLD
HOW A C PROGRAM WORKS

#include <stdio.h>

int main()
{
printf("Hello World\n");
return 0;
}
VARIABLES

Data
15

15

Memory
Each location in the memory is unique

Variables allow to provide a meaningful name for the location in memory


EXPRESSION

¡ Combination of operators and operands, for example:

Operators

2*y+5

Operands
PRINT VARIABLES USING PRINTF()

¡ In C programming language, printf() function is used to print the


“character, string, float, integer, octal and hexadecimal values” onto the
output screen.
¡ Following is the declaration for printf() function:

int printf(const char *format, ...)


printf(“Hello World!”)
TAKING INPUT FROM USER

#include <stdio.h>

int main(){
int x;
x = 5; //Hard Coding
int y = x/2
printf("y= %i, x = %i",y,x);
return 0;
}
TAKING INPUT FROM USER

¡ In C programming, scanf() is one of the commonly used function to take input from
the user.
¡ The scanf() function reads formatted input from the standard input such as
keyboards.
EXERCISES 1

Write a program that prints the perimeter of a rectangle to take its height and
width as input:

Expected Output :
Input the height of the Rectangle : 5
Input the width of the Rectangle : 7
Perimeter of the Rectangle is : 24
EXERCISES 2

Write a program that converts Centigrade to Fahrenheit:

Expected Output :
Input a temperature (in Centigrade): 45
113 degrees Fahrenheit.
EXERCISES 3

Write a program that takes hours and minutes as input, and calculates the total number of
minutes:

Expected Output :
Input hours: 5
Input minutes: 37
Total: 337 minutes.
SUMMARY

¡ The Software Development Method


¡ C Programing Language
¡ C Programming Tools
¡ Write Our First Program – Hello World
¡ Variables
¡ Expressions
¡ printf()/scanf() function

You might also like