{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

t02AFirstCProgram

t02AFirstCProgram - A First C Program...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
A First C Program www.kite-legends.blogspot.com
Image of page 1

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

View Full Document Right Arrow Icon
Dale Roberts Try Your First C Program Try Your First C Program #include <stdio.h> /* I/O header file */ main() main() { printf(“Hello world ”); printf(“Hello world ”); printf(“Welcome to CSCI230\n“); printf(“Welcome to CSCI230\n“); printf(“I am John Smith\n”); printf(“I am John Smith\n”); } A C program contains one or more functions main() is the function name of your main (root) program { }: braces (left & right) to construct a block containing the statements of a function Every statement must end with a ; \ is called an escape character \n is an example of an escape sequence which indicates newline Other escape sequences are: \t \r \a \\ \” Exercise : Use any editor to type and then save your first program as main.c % gcc main.c % a.out and observe its result. header file – contains I/O routines pre-processor directive one statement main must be present in each C program statement terminator Indicates a program building block called function comment www.kite-legends.blogspot.com
Image of page 2
Dale Roberts Identifiers Identifiers Variable identifiers Variable identifiers Begin with a letter or underscore: A-Z , a-z , _ The rest of the name can be letters, underscore, or digits Guarantee that east least the first 8 characters are significant (those come after the 8th character will be ignored) while most of C compiler allows 32 significant characters. Example : _abc ABC Time time _a1 abcdefgh abcdefghi (may be the same as abcdefgh ) Case sensitive Keywords: reserved names (lexical tokens) auto double if static break else int struct case entry long switch char extern register typedef float return union do go sizeof continue www.kite-legends.blogspot.com
Image of page 3

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

View Full Document Right Arrow Icon
Dale Roberts
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern