1 / 15

Beginning C Programming for Engineers CSCI-1190

Basic Computer Model. CPU. Input. . . Memory. . Instructions Data. Von Neumann Architecture. Output. Programming Languages. Machine Languages. Assembly Languages. High-Level Languages. 1300042774 1400593419 1200274027. LOAD AADD BSTORE C. C=A B. . . . . . Creating Programs. hello.o.

niveditha
Download Presentation

Beginning C Programming for Engineers CSCI-1190

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. Beginning C Programming for Engineers (CSCI-1190) Instructor: Gang Chen (cheng3@rpi.edu) Office Hour: Thursday 2-4pm (or by appointment) Office: Lally 9A Webpage: www.cs.rpi.edu/~cheng3/teaching/1190

    3. Programming Languages

    4. Creating Programs

    5. Unix Commands

    6. Hello, World Editing: xemacs hw.c& or nedit hw.c& or vi hw.c Compiling: gcc –Wall –o hello hw.c Executing: hello

    7. Basic Programming Concepts Comment To explain what the program is for and why it is the way it is. Preprocessing Done before the program is compiled. To include header files containing information about C libraries Statement A line of code that tells computer to perform some action. Always ended with a semicolon(;). Invoking functions Function A module often consisting of a set of statements. Two functions in the hello world program: main, printf

    8. In Class Exercise 1-1 Escape Sequences are used to control printf to do something other than printing characters. Modify the hello world program to try out various escape sequences like: \n: Newline. Position cursor at the beginning of the next line. \t: Tab. Move cursor to the next tab stop. \a: Alert. Sound the system bell.

    9. Arithmetic Operators To form expressions Many statements are merely expressions. Normal order of operations is followed. Parentheses can be used. If you are not sure, look up in Appendix C. Operator Precedence Charts, p1193

    10. Arithmetic Operators: An Example

    11. Variables Variable Name for a memory object. Variable names must start with letters and contain letters, digits, and underscores. a, b, i, j, counter, number_of_points, c1234, … Type What the variable represents. Could be of integer, floating point number, character, string, and many others. int, float, double, char, … Declaration Tells compiler about variables and their type. int i,j; float sum;

    12. Numeric Types

    13. Reading Inputs

    14. Assignment

    15. In-Class Exercise 1-2 Write a program to calculate the average of three floating point numbers, namely 2.3, 3.4, 4.5. Using scanf function Using assignment

More Related