Presentation is loading. Please wait.

Presentation is loading. Please wait.

 2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Discussion 1 Commonly used commands Executing program.

Similar presentations


Presentation on theme: " 2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Discussion 1 Commonly used commands Executing program."— Presentation transcript:

1  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Discussion 1 Commonly used commands Executing program hello.c using Ch in ChIDE A sample problem: find the volume of a cylinder The _chrc and.chrc start-up file The _path system variable

2  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Commonly Used Commands Ch supports all Windows commands and most Unix commands CommandUsageDescription cd Change to the home directory cd dirChange to the directory dir cpcp file1 file2Copy file1 to file2 ls List contents in the working directory mkdirmkdir dirCreate a new directory dir pwd Print (display) the name of the working directory rmrm fileremove file chmodchmod +x fileChange the mode of file to make it executable chidechide file.cEdit and execute program file.c vivi fileEdit file

3  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Examples of Commands C:/Documents and Settings/Administrator> cd / C:/> mkdir tmp C:/> cd tmp C:/tmp> mkdir eme5 C:/tmp> cd eme5 C:/tmp/eme5> pwd C:/tmp/eme5 C:/tmp/eme5> cp C:/Ch/demos/bin/hello.c hello.c C:/tmp/eme5> ls hello.c C:/tmp/eme5> chide hello.c

4  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Executing Program hello.c Using Ch in ChIDE Click “Run” or “Start” to execute the program

5  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Files in Ch C:/Ch> pwd C:/Ch C:/Ch> ls bin/ demos/ docs/ include/ license/ README.TXT sbin/ config/ dl/ extern/ lib/ package/ release/ toolkit/ C:/Ch> cd docs C:/Ch/docs> C:/Ch/docs> ls README.TXT chguide.pdf chinstall.pdf chref.pdf man/

6  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Using GIMP to grab an image Download GIMP from http://www.gimp.org/windows/ http://www.gimp.org/macintosh/ http://www.gimp.org/windows/ http://www.gimp.org/macintosh/ Install GIMP Click menu File Click menu Create Click menu Screen Shot Click Grab. Then move the cursor to a window to be acquired. Save or print out the acquired window.

7  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Example 1 Find the volume of a cylinder –Radius: 3.5m –Height: 4.6m

8  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Example 1 (cont.)‏ Find the volume of a cylinder /* File: cylinder.c Calculate and display the volume of the cylinder with the radius of 3.5 meters and height of 4.6 meters */ #include int main() { printf("volume = %f m^3\n", 3.14159*3.5*3.5*4.6); return 0; }

9  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Example 2 Write a program that calculates the area of a rectangle. The length and width of the rectangle are specified in the program.

10  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Example 2 (cont.)‏ /* File: area.c */ #include int main() { double l, w, a; l = 2.5; /* length 2.5 meters */ w = 3.6; /* width 3.6 meters */ a = l*w; printf(“The area is %f m^2\n”, a); return 0; }

11  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach The _chrc and.chrc start-up file The file _chrc in Windows and.chrc in Unix and Mac is the individual start-up file in your home directory, and will be invoked each time when Ch is launched.

12  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Open the startup file _chrc in Windows or.chrc for Unix for editing through ChIDE

13  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach The _path system variable The variable _path in the _chrc or.chrc file is used to set up paths for executable files.


Download ppt " 2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Discussion 1 Commonly used commands Executing program."

Similar presentations


Ads by Google