1 / 5

Programming with C

Discover the advantages of programming with C, a powerful and flexible language. Learn how to edit, compile, and run source code, and explore control structures, input/output, operators, and format specifications.

madridl
Download Presentation

Programming with C

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. Programming with C Sung-Ju Kang Department Of Physics Kangwon National University 1. Advantage of C Language • Powerful and flexible language • Operation plenty • Portable language • Language of low level special quality. 2. Programming with C • Edit and save the source code using the editor (ASCII). $ tc • Compiled the source code. $ tcc filename.c Make an object code. • Run it. $ filename.exe

  2. 3. Generic Program Written by C Main function is main body of program written by c. A sentence is finished the semicolon (;). Subroutines is started ({) and is finished (}). Comments : /* . . . */ or // • Include header files #include <filename.h> #include “filename.h” • Variables declaration Global variables Local variables • Subroutines Return the value Void type • Print the output on the screen

  3. 4. Control Structures in C -Distinguisher • if statements : If “conditions” is TRUE, then run “statements”. If “conditions” is FALSE, then run “statements2”. -Repetition • while statements : Run “statements” while “conditions” is TRUE. can change “conditions”. • for statements : i starts at 1, and run “statements” until i is imax. • do . . . while statements : Run “statements” while “conditions” is a TRUE.

  4. 5. Input and Output in C Input and output to screen Input and output to files

  5. 6. Operators and Format Specifies and Escape sequences in C. Relational operators == : equal != : not equal Logical operators && : AND || : OR ! : NOT Format of output specifies %c : char %s : char* %d : int, short %ld : long %f : float %lf : long double %e : float (form of index) Type cast operators ++ : increase 1 -- : decrease 1 Escape sequences \a : bell, beep \b : backspace \n : new line \t : tap \\ : back slash \‘ : ‘ (quotation mark)

More Related