Presentation is loading. Please wait.

Presentation is loading. Please wait.

Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers.

Similar presentations


Presentation on theme: "Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers."— Presentation transcript:

1 Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers

2 Unit 1 Introduction to C Programming Content Covered: Problem Solving and Program Design in C: Chapter 1, Overview of Computers and Programming Chapter 2, Overview of C, pp , Sections

3 Unit 1 Introduction to C Programming Objectives 1. Create a C program that performs input, processing, and output. 1.1: Describe the ways a program can receive input. 1.2: Describe how data is stored in and accessed from memory and secondary storage devices. 1.3: Compare operating system and application software. 1.4: Describe the purpose of a compiler. 1.5: Describe the steps in the software development method. 1.6: Describe the general format of a C program. 1.7: Write code that uses input and output functions. 1.8: Add comments to document a program.

4 Unit 1 Introduction to C Programming Objectives – Cont… 2. Write a program that uses variables and constants. 2.1: Define constant macros to improve program readability. 2.2: Recognize standard identifiers, user-defined identifiers, and reserved words. 2.3: Demonstrate the ability to declare and use variables in a C program. 2.4: Write code that uses an assignment statement. 3. Apply modular programming techniques to C programming. 3.1: Write code that uses libraries.

5 Unit 1 Introduction to C Programming 1. Memory 2. Secondary storage 3. Central processing unit 4. Input/output devices 5. Networks 6. Operating system vs. applications 7. Compilers 8. Software development method 9. Preprocessor directives 10. main Function 11. Identifiers 12. Constants 13. Variables 14. Assignment statement 15. Input and output functions 16. General form of a C program 17. Comments Key Concepts and Objectives

6 Figure 1.3 Components of a Computer

7 Figure 1.5 Relationship between a Byte and a Bit

8 Figure 1.11 Entering, Translating, and Running a High-Level Language Program

9 Figure 1.12 Flow of Information during Program Execution

10 Problem Solving

11 The Software Development Method 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.

12 The HELLO WORLD! Program in several languages

13 Various Language Examples Basic 10 print"Hello World! 20 goto 10 C #include main() { for(;;) { printf ("Hello World!\n"); } }

14 #include main() { for(;;) { cout << "Hello World! "; }} C++ H FSCREEN O F CRT C EXCPT OSCREEN E 1 O 12 'HELLO WORLD!' RPGLE

15 IDENTIFICATION DIVISION PROGRAM-ID. HELLOWORLD DATE-WRITTEN. 02/05/96 21: * AUTHOR BRIAN COLLINS ENVIRONMENT DIVISION CONFIGURATION SECTION SOURCE-COMPUTER. RM-COBOL OBJECT-COMPUTER. RM-COBOL DATA DIVISION FILE SECTION PROCEDURE DIVISION MAIN-LOGIC SECTION BEGIN DISPLAY " " LINE 1 POSITION 1 ERASE EOS DISPLAY "HELLO, WORLD." LINE 15 POSITION STOP RUN MAIN-LOGIC-EXIT EXIT. COBOL

16 begin: print "Hello World!" goto begin QBASIC Pascal Program Hello (Input, Output); Begin Writeln ('Hello World!'); End. Perl print "Hello, World!\n" while (1);

17 Hello, World Page! Hello, World! HTML class HelloWorld { public static void main (String args[]) { for (;;) { System.out.print("Hello World "); } Java

18 JavaScript Hello World in JavaScript document.write ("Hello, world!") Dos batch off :top echo "Hello, World!" goto top

19

20 C Programming C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix... C (pronounced "See") is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. Although C was designed for implementing system software, it is also widely used for developing portable application software. C is one of the most popular programming languages and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which originally began as an extension to C. en.wikipedia.org/wiki/C_programming:

21 C Reserved Words autodoubleincludestatic breakelifintstruct caseelselongswitch charenummaintypedef constexternregisterunion continuefloatreturnunsigned defaultforshortvoid definegotosignedvolatile doifsizeofwhile

22 C Program Example #include #define PI /*Your name*/ /*This program accepts the radius of a circle, calculates the area, and outputs the radius and the area.*/ int main(void) { double radius; /*Stores the radius entered by the user*/ double area; /*Stores the area after the calculation*/ printf("Enter the radius of the circle>"); scanf("%lf", &radius); area = PI * radius * radius; /*Calculates the area as PI */ /*and stores the results in area*/ printf("The area of a circle with a radius of %f is %f\n", radius, area); return (0); }

23 The Software Development Method 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.

24 Algorithm to Program Include required libraries Define constants Declare variables Get the input Perform process to transform input into the output Display output Refine the program

25 Preprocessor Directives Provide instructions to the preprocessor. Begin with # #include Used to load a library, such as a standard library #include #define Used to define a constant macro #define PI

26 Function main The point at which program execution begins Contains declarations and executable statements Standard format is: int main(void) { /*declarations*/ /*executable statements*/ return (0);}

27 scanf Function scanf("%lf", &variable name); Read the floating point number into the address of the memory cell referenced by the variable miles.

28 printf Function printf("That equals %f kilometers.\n", kms); function name function arguments format string print list That equals kilometers


Download ppt "Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers."

Similar presentations


Ads by Google