t02AFirstCProgram

T02AFirstCProgram - A First C Program www.kite-legends.blogspot.com Try Your First C Program#include main Indicates a cfw program

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

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

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

View Full DocumentRight Arrow Icon
Dale Roberts Try Your First C Program Try Your First C Program #include <stdio.h> /* I/O header file */ #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
Background 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
Background image of page 3

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

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

This note was uploaded on 12/08/2010 for the course CSE 2017 taught by Professor Kittu during the Spring '10 term at APIIT.

Page1 / 14

T02AFirstCProgram - A First C Program www.kite-legends.blogspot.com Try Your First C Program#include main Indicates a cfw program

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

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