1 / 23

Software

Software. John Sum Institute of Technology Management National Chung Hsing University. Lecture Outline. Types of Software System Software Application Software Programming Language Language Translation Computer System versus Firm C Programming. C Programming. Algorithms and Pseudo Code.

adila
Download Presentation

Software

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. C Programming

  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<stdio.h> 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. #include<stdio.h> 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”); } Example 2: Input data to an array

  10. #include<stdio.h> 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”); } Example 3: Sorting data

  11. Structure • #include<stdio.h> • 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”); }

More Related