UCSD PHYS 121 - C-Programming (24 pages)

Previewing pages 1, 2, 23, 24 of 24 page document View the full content.
View Full Document

C-Programming



Previewing pages 1, 2, 23, 24 of actual document.

View the full content.
View Full Document
View Full Document

C-Programming

64 views


Pages:
24
School:
University of California, San Diego
Course:
Phys 121 - Experimental Techniques

Unformatted text preview:

C Programming Part I basics prep for Lab 8 UCSD Physics 121 2012 Why C See http www tiobe com tpci htm 02 07 rank 02 06 rank movement Language share in last year 1 1 Java 18 978 3 45 2 2 C 16 104 2 23 3 3 C 10 768 0 53 4 5 PHP 8 847 0 07 5 4 Visual Basic 8 369 1 03 6 6 Perl 6 073 0 63 7 8 Python 3 566 0 90 8 7 C 3 189 0 78 9 10 JavaScript 2 982 1 47 10 20 10 Ruby 2 528 2 12 Winter 2012 2 UCSD Physics 121 2012 C How it Stacks Up As U can C the C language and its extensions derivatives dominates the software community Java also a strong showing Python worth a peek Advantages of C compiled code runs FAST allows low level device control a foundation of the programming world Disadvantages of C strings are a pain in the awkward conventions pointers can be difficult to learn requires a compiler Winter 2012 3 UCSD Physics 121 2012 What we will and won t do We will learn to write simple programs basic interface control flow math printing data types enough to be dangerous We won t learn advanced pointer operations large projects linking separate programs distinctions between public private external variables enough to be really dangerous Winter 2012 4 UCSD Physics 121 2012 C File Types Source Code the stuff you type in has c extension Compiled Executable the ready to run product usually no extension in Unix exe in DOS Header Files contain definitions of useful functions constants h extension Object Files a pre linked compiled tidbit o in Unix obj in DOS only if you re building in pieces and linking later Winter 2012 5 UCSD Physics 121 2012 A typical short program include stdio h int main void int i 53 printf The illustrious variable i is d n i return 0 Notes first include is so we have access to printf standard I O define the main program must be called main to take no arguments thus void and return an integer braces surround the program print value of integer i in formatted line return zero common return value for successful program Winter 2012 6 UCSD Physics 121 2012 More



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view C-Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view C-Programming and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?