cp_1_lect_18 - Introduction to C Programming History of C...

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

View Full Document Right Arrow Icon
Introduction to C Programming
Background image of page 1

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

View Full DocumentRight Arrow Icon
History of C 1960 ALGOL International Group 1967 BCPL Martin Richards. 1970 B Ken Thompson 1972 Traditional C Dennis Ritchie 1978 Kerneighan and Ritchie 1989 ANSI C ANSI Committee 1990 ANSI/ISO ISO committee 1999 C99 Standardization committee Ø Kerneighan Dennis Ritchie
Background image of page 2
This is a comment – starts with a /* and ends with a */. Comments are used to explain the program to human readers, and are ignored by the compiler. Curly braces indicate the beginning and end of a block of instructions. In this case we give the block the name main. This is an instruction to the compiler to insert the contents of the file stdio.h to the program prior to compilation. This file contains information about the printf command. Yet another C statement. This one terminates the program and informs the operating system that it has ended successfully. This tells the compiler we are about to define a block of commands called main. main is a special block – it is where the program starts running. This is a C statement. This statement execute the command printf, which causes text to be printed on the screen. Note that all C statements end with a semicolon (;). Our first C program: best way to learn /* HelloWorld – An example program */ #include <stdio.h> int main( ) { printf(“Hello, world!\n”); return 0; } How many functions are there here? Lower case and Uppercase
Background image of page 3

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

View Full DocumentRight Arrow Icon
Anatomy of a C Program Program header comment Preprocessor directives Global declarations int main ( void ) { Local declarations Statement(s) return 0 ; }
Background image of page 4
Program Header Comment A comment is descriptive text used to help a reader of the program understand its content. All comments must begin with the characters /* and end with the characters */ These are called comment delimiters The program header comment always comes first. Look at the class web page for the required contents of our header comment.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Preprocessor Directives Lines that begin with a # in column 1 are called preprocessor directives (commands). Example: the #include <stdio.h> directive causes the preprocessor to include a copy of the standard input/output header file stdio.h at this point in the code. This header file was included because it contains information about the printf ( ) function that is used in this program.
Background image of page 6
stdio.h When we write our programs, there are libraries of functions to help us so that we do not have to write the same code over and over. Some of the functions are very complex and long.
Background image of page 7

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

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

This note was uploaded on 05/07/2010 for the course CS&IS TA C162 taught by Professor Kavitha during the Spring '09 term at Birla Institute of Technology & Science.

Page1 / 33

cp_1_lect_18 - Introduction to C Programming History of C...

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

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