Week03 - ENEE 140: Introduction to Programming Concepts for...

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

View Full Document Right Arrow Icon
ENEE 140: Introduction to Programming Concepts for Engineers gangqu@umd.edu © Gang Qu Spring 2010 Week 3 Variables and Data Types Lab report: Answer the questions in lab 5 only, including those whose answers are given by the TA in the lab, in one file and name it week03.txt. Submit by the following command: submit 2010 spring enee 140 010? 1 week03.txt Due: 11:59 pm Monday, February 22. Lab 5: Monday February 15 (lab on Feb. 8 cancelled due to snow) 1. Basic lab skills: make sure that you know the following by now a. log in your GLUE account from PC and Linux b. access class webpage at bb.eng.umd.edu c. access the GLUE class public directory d. UNIX text editor: vi or emacs e. Use submit command to electronically submit your assignment 2. Read the following about program (supposed to be covered in the lecture) a. A program is a set of instructions that a computer can execute to accomplish a given task. The form of the program that a computer can execute is called executable (also known as machine code, object code , or binary code ). The executable is normally generated by a computer software called compiler from source code written by in high level programming languages such as C or C++. b. What we will learn in this class is how to write C source code, compile it under UNIX, and run the executable to solve the given problem. i. Use any UNIX text editor to create a file with extension .c. For example, vi hello.c This will be your C source code. ii. Follow the syntax (grammar rules) of C to document and write the instructions to solve the given problem. Save the file. iii. Use GLUE C compiler to compile your source code. For example, gcc hello.c If compilation is correct, an executable will be generated under the name a.out use –o option to specify the name of the executable. For example, gcc hello.c –o hello will generate an executable called hello iv. Execute the executable by typing in the file name. For example, a.out c. Key components of C code by an exmple: 1) /* This program, once compiled and executed, will print out the 2) sentence "Hello, World!" on the display. 3) This is considered as the first C program in honor of 4) Dennis Ritchie who invented C at Bell lab in 1972. 5) This is also my first C program. 6) Joe Doe
Background image of page 1

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

View Full DocumentRight Arrow Icon
ENEE 140: Introduction to Programming Concepts for Engineers gangqu@umd.edu © Gang Qu Spring 2010 7) Feb. 10, 2010 8) */ 9) #include <stdio.h> 10) int main(void) 11) { 12) printf("Hello, World!\n"); 13) return 0; 14) } i. Documentation : purpose of the program, programmer, time developed, history of revision. Appears as comment (see below for more about comments) in lines 1)-8). ii. Preprocessing : include library files (called header file in line 9), define some variables, functions, etc. (not shown in the example, but we will see more about this in the future). iii.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/11/2010 for the course ENEE 140 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 9

Week03 - ENEE 140: Introduction to Programming Concepts for...

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

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