Lecture 1 - Chapter 1 Getting Started Outline A Simple C...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 1 Getting Started Outline A Simple C Program Run Program hello.c Startup in Ch Command chmod in Unix Ch Scripts Interactive Command Mode Command Mode Startup in Sample Problem A Simple C Program /* File: hello.c */ #include <stdio.h> int main() { printf(Hello, world\n"); return 0; } Comments Text surrounded by /* and */ is ignored by computer Used to describe program #include <stdio.h> Preprocession directive - tells computer to load contents of a header file <stdio.h> allows standard input/output operations int main() C programs contain one or more functions, exactly one of which must be main Parenthesis used to indicate a function int means that main "returns" an integer value Braces indicate a block The bodies of all functions must be contained in braces printf( hello, world\n" ); Instructs computer to perform an action Specifically, prints string of characters within quotes Entire line called a statement All statements must end with a semicolon \- escape character Indicates that printf should do something out of the ordinary \n is the newline character \a is the character for a sound. return 0; A way to exit a function return 0 , in this case, means that the program terminated normally The returned value of 0 is displayed in the exit status in ChSciTE Right brace } Indicates end of main has been reached Run Program hello.c Run program hello.c in VC++ > cl hello.c /* ... create hello.exe */ > hello.exe Hello, world Run program hello.c in Unix/Linux/Mac OS X > cc hello.c Or > gcc hell.c /* ... create a.out */ > a.out Hello, world Run program hello.c in Ch....
View Full Document

This note was uploaded on 04/16/2008 for the course MATH 21A taught by Professor Osserman during the Fall '07 term at UC Davis.

Page1 / 20

Lecture 1 - Chapter 1 Getting Started Outline A Simple C...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online