1 / 29

Intro to Art of Programming

Intro to Art of Programming. Math 130 Lecture # 01 01/24/05. B Smith: Reconsider these topics upon completion of lecture. Overview. Programming Style. Brace placement White space Indentation Comments. Interesting style. What does it do?. Obfuscated code output. Obfuscated code.

Download Presentation

Intro to Art of Programming

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. Intro to Art of Programming Math 130Lecture # 0101/24/05

  2. B Smith: Reconsider these topics upon completion of lecture Overview

  3. Programming Style • Brace placement • White space • Indentation • Comments

  4. Interesting style. What does it do?

  5. Obfuscated code output

  6. Obfuscated code • That was an extreme example of bad style • The code works beautifully, but I feel sorry the person who inherits Ed's code after he moves on • White space is important

  7. ex. brace placement

  8. White space • Program structure should make sense without having to study each line of code for 2 hours • Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate. Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate. Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for co mprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.Whitespace is important for comprehending most any information that one wishes to communicate.

  9. Indentation

  10. Comments • Explanatory remarks within a program • Used to clarify intention of program • /* and */ can be placed anywhere within a program • On your own, try placing a comment in the middle of your “hello there world” output line. • Comments can not be nested! • /* starts out ok /* goes wrong */ here . Kaboom */

  11. Top Down Program development • Start w/ the end; detemine the desired output • Determine inputs • Select an algorithm and verify the logic • Write the program • Test program with data

  12. Common errors

  13. _ Basic data types in C • Integer • Floating point • Double precision • Character

  14. Variables

  15. Storage requirements • 1 byte = +/- 127 • 2 bytes = +/- 32k • 4 bytes = +/- 2 Gigabytes

  16. Other data types • The beauty of C • Abstraction

  17. The sizeof() function • Mac vs PC

  18. Float and Double

  19. ASCII characters

  20. Lab 02 – Overview • The Integrated Development Environment (IDE) • MS Visual Studio • Blackboard • overall layout • Submitting assignments • Checking your grades • Communication and feedback

  21. BB

  22. An example • The canonical “hello world”: #include <stdio.h> int main() { printf("Hello there world!"); return 0; }

  23. From Dev-C

  24. Dev-C requesting user input

  25. Borland's Turbo C++

  26. Using DJGPP

  27. Entering a program • Edit the program • Save with appropriate filename • *.c, *.cc, *.C, *.cppetc. • Compile • Link (sometimes done automatically) • Run the program

  28. Edit and Save

  29. Run the program...

More Related