Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 1 ECE15: Introduction to Computer Programming Using the C Language

Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 1 ECE15: Introduction to Computer Programming Using the C Language

Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 1 ECE15: Introduction to Computer Programming Using the C Language 1: Introduction A. Orlitsky and A. Vardy, based in part on slides by S. Arzi, G. Ruckenstein, E. Avior, S. Asmir, M. Elad. ECE15 – Engineering Computation – Fall 15 Whe(n/re) Class WLH 2001 TTh 2:00–3:20 Sections Peter 102 M 4–4:50 Peter 103 M, W, F 3–3:50 Office hours Jacobs 4307 M 9-1; Tu 11-2, 3:30-6; W 9-1, 5-8; Th 11-2; F 11-2 Instructor Alon Orlitsky Atk 4109 M 2-3 TA’s David Hall, Raghav Abboy, Neha Ahlawat, Vijay Chintalapudi, Moein Falahatgar, Shengyao Guo, Pranav Markani, Anton Qiu, Sitanan (Spipe) Tanyasakulkit, Hans Yu, Allen Zhao Grading 30% Weekly homework sets, worst omitted 20-30% Midterm, Th 11/5 2-3:20 40-50% Final, Th 12/10 3-6 Midterm / final weight chosen to maximize your score Homework Homework is crucial to understanding the material. Please take it seriously. Up to 4 problems will be assigned weekly except before the midterm and final. Please upload your solutions online by noon the following Thursday. You may generally discuss the homework with others, but do not look at anyone else’s code, nor show them yours. Regrades Regrade requests must be submitted with explanation in writing within two weeks from the day the grade was assigned. Website HW’s, solutions, announcements: http://ece15.info Grades: http://ted.ucsd.edu Discussions: http://piazza.com Feedback Send all email correspondence to ecefi[email protected]. Textbooks Programming in C, 3rd Edition, Stephen G. Kochan, Developer’s Library The C Programming Language, 2nd Ed., Kernighan and Ritchie, Prentice Hall, 1988 Syllabus Approximate topics, order covered, and corresponding material in Kochan 4th Edition. For 3rd Ed. just increment chapter by one (e.g. 2 becomes 3) pages are essentially the same. Lecture Topics Chapter: Pages 1 introduction, first program, compiling 2: 11-19 2 variables, types, input, output 3: 21-30, 15: 345-362 3 math: operations, expressions, logic 3: 30-39 4 control flow: conditionals, loops 5: 65-92, 4: 43-62 5 algorithms (maybe move to later) review 6 arrays, multi-dimensional arrays 6: 95-116, 9: 193-215 7 functions, scope, modular design 7: 119-158 8 pointers, dynamic memory allocation 10: 233-274 Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 3 Why Grades ❖ Necessary evil Hello Hello! ❖ Non-reasons ‣Judge ‣Easy ‣Cool ❖ Top 8 reasons ‣Without: show up only at graduation ‣Worse: not just class empty! ‣Helps you know what you know ‣Helps us know what you know ‣Encourage to perform, excel ‣Helps you in future ‣Evolution Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 4 Expectations ❖ High-school GPA? Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 5 Calibration ❖ What grades stand for Generic High Amazing! Average A Autstanding! Acceptable Anbelievable! B Bummer Brilliant C Catastrophe Cool Drama Detraction D Disaster Do it again Death ❖ Conclusion: Don’t panic if you get a B or a C! Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 6 Homework ❖ Teach you the most ❖ Weekly assignments ❖ 3-4 problems ❖ To help you: Website, Ted, Piazza ❖ Daily recitation sections and office hours ❖ If not enough, let us know ❖ Discuss with friends ❖ Don’t copy - write your own ❖ We’ll check, and follow up! Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 7 Gradual Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 8 How Hard is the Course? ❖ Easy ‣Introductory ‣Different backgrounds ‣From scratch ‣No prior programming assumed ‣Everything should be clear ❖ Difficult ‣First course ‣Learn a new language ‣New way of thinking ‣Homework Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 9 Ready? Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 10 What’s the Course About? Programming - Making computers do what we want C - Powerful multi-purpose programming language, most popular, and basis for C++, Java, Python, other languages Modular design - Philosophy of breaking tasks into components, implementing each, then combining Programming used everywhere One of the most useful classes you will take! Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 11 First Lecture Outline ❖ Operating systems ‣Unix ❖ Editors ‣Emacs ❖ Compiling and running ‣Create, compile, run (crash) ❖ The first C program ‣Hello world ❖ Programming style ‣White space, indentation, comments Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 12 Operating Systems ❖ Oversee computer operations ❖ Interface computer, peripherals, humans ❖ Common varieties ‣DOS ๏Windows + XP + Vista + 7 + 8 ‣Unix + Linux ๏Mac OS ๏... iOS, Android, ... ❖ And the winner (at least in ECE15) is: ‣Unix Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 13 Unix Commands ❖ Prompt (here > ) means ready for next command ❖ Run command by typing its name > ls info story ‣Type arguments after name > more info Observing Files I can write ❖ ls - list files in current directory (almost) anything ❖ more - print files on screen > more story ‣more name - prints file called name Once upon a time... > cp story tale Moving and Removing Files > ls ❖ cp - copy (duplicate) file info story tale ‣ cp name1 name2 - copy name1 to name2 > more tale ‣ both will have identical contents Once upon a time... ❖ mv - move (rename) file > rm story ‣ mv name1 name2 - move name1 to name2 remove story? y ‣name1 disappears, contents in name2 - remove files > ls ❖ rm info tale ‣rm name - remove file called name Lecture 1 ECE15: Introduction to Computer Programming Using the C Language > 14 More UNIX Commands Directories (Folders) ❖ mkdir - create a subdirectory in current directory ‣mkdir name - create a directory called name ❖ cd - change directory ‣cd name - change to directory name ‣. current directory, .. parent directory, ~ home directory, - previous directory ❖ rmdir - remove directory ‣rmdir name - remove directory name ❖ pwd - path to preset working directory Other Commands ❖ date, cal ❖ Even more commands? See Website ❖ What’s missing? Create a file! Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 15 First Lecture Outline ❖ Operating systems ‣Unix ❖ Editors ‣Emacs ❖ Compiling and running ‣Create, compile, run (crash) ❖ The first C program ‣Hello world ❖ Programming style ‣White space, indentation, comments Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 16 Creating a File ❖ Text editor ❖ Not rich text format editors: word ❖ Plain text editor And ‣wordpad the winner ‣VI/VIM is..... ‣Emacs Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 17 Emacs Commands ❖ Run by typing: > emacs “filename” ❖ Start typing ❖ Move around: arrow keys ❖ Save: ctrl-x ctrl-s ❖ Exit: ctrl-x ctrl-c Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 18 Example > ls > emacs test > ls test > more test This is an emacs text editor I can type anything I wish So easy At the end I: * save (ctrl-x ctrl-s) * exit (ctrl-x ctrl-c) > Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 19 First Lecture Outline ❖ Operating systems ‣Unix ❖ Editors ‣Emacs ❖ Compiling and running ‣Create, compile, run (crash) ❖ The first C program ‣Hello world ❖ Programming style ‣White space, indentation, comments Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 20 C Program Files ❖ Source-code file ‣We create ‣Almost English ❖ Executable file ‣Generated from source file ‣By a compiler ‣Gibberish to us ‣Computer understands ❖ Need to know ‣Create source ‣Compile it to create executable ‣Run executable Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 21 First Lecture Outline ❖ Operating systems ‣Unix ❖ Editors ‣Emacs ❖ Compiling and running ‣Create, compile, run (crash) ❖ The first C program ‣Hello world ❖ Programming style ‣White space, indentation, comments Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 22 “First C Program” First C tutorial, 1974: Its first program: Programming in C A Tutorial main() { ߝ printf(“hello, world”); } Brian W. Kernighan Bell Laboratories, Murray Hill, N. J. Nowadays: #include <stdio.h> int main() { printf("hello, world"); 1. Introduction return 0; C is a computer language available on the GCOS and UNIX operating systems at Murray Hill and (in } preliminary form) on OS/360 at Holmdel. C lets you write your programs clearly and simply _ it has de- cent control flow facilities so your code can be read straight down the page, without labels or GOTO’s; it lets you write code that is compact without being too cryptic; it encourages modularity and good program organization; and it provides good data-structuring facilities. Lecture 1 ECE15: Introduction to Computer Programming Using the C Language 23 This memorandum is a tutorial to make learning C as painless as possible. The first part concentrates on the central features of C; the second part discusses those parts of the language which are useful (usually for getting more efficient and smaller code) but which are not necessary for the new user. This is not a ref- erence manual. Details and special cases will be skipped ruthlessly, and no attempt will be made to cover every language feature. The order of presentation is hopefully pedagogical instead of logical. Users who would like the full story should consult the C Reference Manual by D. M. Ritchie [1], which should be read for details anyway. Runtime support is described in [2] and [3]; you will have to read one of these to learn how to compile and run a C program. We will assume that you are familiar with the mysteries of creating files, text editing, and the like in the operating system you run on, and that you have programmed in some language before.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    37 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us