



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




1
2
n Why C? n C is a general purpose programming language n Efficient and popular n Other programming languages: C++, Java, Matlab, etc n Software n Microsoft Visual Studio C++ 6.0 (included in the book) n Microsoft Visual Studio .net (available at computer labs: SE322, CS21, CS21A, Math & Science Center etc) n Textbook n C How to Program, Prentice-Hall, by Deitels n We only cover Chapter 1 to Chapter 13 n Excellent book for you to self-study C++ and Java
3
n Create n Type in the source code of the program (.c, .h files)
n Compile n Convert the source code into machine code (generate .exe file)
n Run n Tell the computer to run your program (run the .exe file)
n Simple programming concepts
4
5
Click the menu item File | New | Project....
A dialog box is displayed.
6
click OK to continue
7
Click Application Settings on the left side of the window and then place a check in the box marked Empty project. The screen should look like this:
8
click OK to continue
13
n To execute your program click the menu item
! Start Without Debugging
14
/* Hello program */
#include <stdio.h>
int main() { printf( "Hello!\n"); return 0; }
15
/ Hello program /
n /* … */ marks a comment block
n Anything in comments is ignored by the compiler
n Extremely useful for including explanatory information
n You can add comments anywhere in a program
16
#include <stdio.h>
n #include n a C preprocessor command n lets you include the code from another file (such as a library) n stdio.h n the standard input-output library n < > means the file stdio.h is in C library directory n “ ” means the file is in the current directory n #include <stdio.h> n allows you to use code from the standard I/O library
17
int main() { ... } n It is a function, only one main function in each program n Curly brackets { } mark the start and the end of the function n Statements of a function are enclosed in { } n Program execution begins at main() n Empty () means main function has no argument. You may also use int main (void) n int means the main function returns an integer. Don't be too concerned about what this means.
18
printf(“Hello!\n”); return 0; }
n Statements of the main function n All statements are terminated by a semicolon n Statements are executed in sequence, from top to bottom
19
printf( "Hello!\n");
n A function defined in stdio.h
n Prints out the message “Hello!” to the screen n “Hello!\n” is a string consisting of a series of characters n \n is a new line character n begin a new line of text after the message
20
return 0;
n Terminates the execution of main() n Indicates that main() returns the value 0