1 Software John Sum Institute of Technology Management National Chung Hsing University.

Slides:



Advertisements
Similar presentations
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Advertisements

1 ICS103 Programming in C Lecture 5: Introduction to Functions.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 ICS103 Programming in C Lecture 3: Introduction to C (2)
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
Guide To UNIX Using Linux Third Edition
1 Agenda - Loops while for for & while Nested Loops do-while Misc. & Questions.
Basic Input/Output and Variables Ethan Cerami New York
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Computer Science 210 Computer Organization Introduction to C.
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
CHAPTER 2 PART #3 INPUT - OUTPUT 1 st semester King Saud University College of Applied studies and Community Service Csc
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
1 ICS103 Programming in C Lecture 7: Introduction to Functions.
NA2204.1jcmt CSE 1320 Intermediate Programming C Program Basics Structure of a program and a function type name (parameters) { /* declarations */ statement;
Arrays  Array is a collection of same type elements under the same variable identifier referenced by index number.  Arrays are widely used within programming.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
1 C Programming Week 2 Variables, flow control and the Debugger.
Lecture 3: Getting Started & Input / Output (I/O) “TRON” Copyright 1982 (Walt Disney Productions)
UniMAP SemI-09/10EKT120: Computer Programming1 Week 5 – Functions (1)
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
1 Programming a Computer Lecture Ten. 2 Outline  A quick introduction to the programming language C  Introduction to software packages: Matlab for numerical.
Computer Programming for Engineers
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Functions Dr. Sajib Datta Functions A function is a self-contained unit of program code designed to accomplish a particular task. Some functions.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Sesi 0607EKT120/4 Computer Programming Week 5 – Repetition / Loops.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Lecture 3: Getting Started & Input / Output (I/O)
Lecture2.
User-Written Functions
Computer Science 210 Computer Organization
Zhang Hongyi CSCI2100B Data Structures Tutorial 3
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
INC 161 , CPE 100 Computer Programming
Chapter 2 - Introduction to C Programming
Computer Programming Chapter 1: Introduction
ICS103 Programming in C Lecture 3: Introduction to C (2)
Functions Dr. Sajib Datta
Lecture 4 - Loops UniMAP EKT120 Sem 1 08/09.
Getting Started with C.
Chapter 2 - Introduction to C Programming
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Control Structures Lecture 7.
Computer Science 210 Computer Organization
Functions Declarations CSCI 230
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Software John Sum Institute of Technology Management
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Lecture3.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Introduction to C Programming
Getting Started With Coding
Presentation transcript:

1 Software John Sum Institute of Technology Management National Chung Hsing University

2 Lecture Outline Types of Software System Software Application Software Programming Language Language Translation Computer System versus Firm C Programming

3

4 Algorithms and Pseudo Code To understand the following slides, you should have knowledge in algorithms and pseudo code. Algorithm describes in detail steps how a task (e.g. sorting) can be accomplished. Pseudo code is a description of the detail steps. It makes use of English-like sentences to describe each of the steps. Clearly, you can also describe the detail steps by using complete English sentences. However, the length will be too long. For mathematical problem, we can also include mathematical equations in the pseudo code. There is no specify format for pseudo code. As long as you and your team members could understand, it will be fine.

5 Selection of Language

6 Example The program codes listing in the next three slides have already been compiled. You could copy them to your DevC editor and compiler to see what happen. In DevC, you can find from the top menu an option “Execute”. Move the cursor to it, you will see “Compiler and run”. Click it, the DevC will compiler the program (if there is nothing wrong), call out a console and then show the results.

7 Example If there is something wrong, please double check if there is any typo error, if there is any missing symbols (e.g. “;”) or if you have broken a single command into two lines.  Correct: printf(“This is my first program.”);  Error: printf(“This is my first program.”)  Error: printf(“This is my first program.”);

8 Example 1: Simple input/output #include int main() /* Main function. */ { int Age; /* Define integer variable Age. */ int Weight; /* Define integer variable Weight. */ printf("Enter your age: "); scanf("%d", &Age); printf("Enter your weight: "); scanf("%d", &Weight); printf("Your age is %d and your weight is %d\n", Age, Weight); systems(“pause”); }

9 Example 2: Input data to an array #include int main() { int A[5]; /* Define integer array. */ int i; /* Define index. */ int total=0; /* Define index. */ printf("This program demonstrates how to do sorting.\n"); printf("Please enter 5 numbers.\n"); for(i=0; i<5; i++) { printf("Enter the %d number: ", i+1); scanf("%d", &A[i]); } printf("The numbers are %d %d %d %d %d.\n", A[0], A[1], A[2], A[3], A[4]); for(i=0; i<5; i++) { total = total + A[i]; } printf("The total sum is %d.\n", total); systems(“pause”); }

10 Example 3: Sorting data #include int main() { int A[5]; /* Define integer array. */ int i,j; /* Define indices i,j. */ int tmp; /* Dummy variable. */ printf("This program demonstrates how to do sorting.\n"); printf("Please enter five numbers.\n"); for(i=0; i<5; i++) { printf("Enter the %d number: ", i+1); scanf("%d", &A[i]); } printf("The numbers are %d %d %d %d %d.", A[0], A[1], A[2], A[3], A[4]); for(i=0; i<4; i++) for(j=0; j<4-i; j++) { if(A[j] > A[j+1]) { tmp = A[j]; A[j] = A[j+1]; A[j+1] = tmp; } printf("The sorted numbers are %d %d %d %d %d.", A[0], A[1], A[2], A[3], A[4]); systems(“pause”); }

11 Structure #include  To include the library file called “stdio.h”.  It lets the compiler to get the definitions of “printf()” and “scanf()”.  For some advanced applications, you might need to include other library files, e.g. “string.h” defines string handling functions and “math.h” defines mathematical functions.  “stdio.h” defines functions for handling standard input-output, such as keyboard input, screen output, reading from file and writing to file.

12 Structure Main function int main() { Declare data type and size Program statements } The first part of “main()” is for data declaration. All the variables and their types have to be clearly defined in here. All the program statements (or so called commands) follow after data declaration.

13 Structure For each data declaration, there must be a “;” added in the end. int A[5]; /* Define integer array. */ int i,j; /* Define indices i,j. */ int tmp; /* Dummy variable. */ “/* */” is called a remark. “ /* ” and “ */ ” indicates the starting and the ending of a remark. Once the compiler sees these two symbols, it will ignore everything inside.

14 Structure For program statements, you also have to add “;” in the end of each command. printf("Enter your age: "); scanf("%d", &Age); printf("Enter your weight: "); scanf("%d", &Weight); Guess if I change the above commands like the following, would it affect the output of the program. printf("Enter your age: "); /* Data input */ scanf("%d", &Age); /*Data input */ printf("Enter your weight: "); /* Data input */ scanf("%d", &Weight); /* Data input */

15 Structure How about the following change? Would it affect the output of the program. printf("Enter your age: "); /* printf("Enter your height: "); */ scanf("%d", &Age); /*Data input */ printf("Enter your weight: "); /* printf("Enter your score: "); */ scanf("%d", &Weight); /* Data input */ For both of the above changes, they work the same way as the original program. It is because the “Data input” and the “printf()” are added inside the remarks. They are ignored.

16 Review Questions What are the differences between system software and application software? What are the basic functions of an operating systems? Describe the difference between utility program and application program. Name three common utilities that can be found in Window XP.

17 Review Questions What is system programming? Name one programming language that should be commonly used for system programming? What is a device driver? A browser like IE is able to read and understand an HTML file. What kind of translator does a browser have, an interpreter or a complier?

18 Review Questions Is it able to use a GCJ to compile a C program? In each C program, the first few lines must be “#include<>”. What is the purpose of adding this include statement? What is the structure of a C program?

19 Review Questions What will be the values of ‘k’ and ‘j’ once the following program segment has been executed? What will you see on the screen? k=0; for(j=0; j< 5; j++) { printf(“*”); k = k+2; }

20 Review Questions What will be the values of ‘k’ and ‘j’ once the following program segment has been executed? What will you see on the screen? k=0; for(j=0; j< 5; j++) { printf(“*\n”); k = k+1; }

21 Review Questions What will be the values of ‘k’ and ‘j’ once the following program segment has been executed? What will you see on the screen? k=0; j= 0; while(j < 5) { printf(“*”); k = k+1; j = j+2; }

22 Review Questions What will be the values of ‘i’, ‘j’ and ‘k’ once the following program segment has been executed? What will you see on the screen? L = 5; W = 10; k = 0; for(i=0; i<L; i++) { for(j=0; j < W; j++) { printf(“*”); k = k+1; } printf(“\n”); }

23 Review Questions What will be the values of ‘i’, ‘j’ and ‘k’ once the following program segment has been executed? What will you see on the screen? L = 5; W = 10; k = 0; for(i=0; i<L; i++) { for(j=0; j < W; j++) { if (i*j > 0) { printf(“*”); k = k+1; } printf(“\n”); }