The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

12
The C Language 1/29/15

Transcript of The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Page 1: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

The C Language

1/29/15

Page 2: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Quiz

• Take quiz 1 on Blackboard• Over vim, linux, and Chapter 1.

Page 3: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Assignment

On your own, answer the following questions. – p.17 #1– p. 31 #3

Edit, compile and execute this program. – p. 57 #3– submit jjarboe cs115 2

Read pp. 65-94 and Chapter 3 for next week.

Page 4: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

C is a Functional Language

Example program ch2/retail.c

Existing functions serve as basis for new functions.

printf and library function used to create main

Page 5: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

main Function

Exactly one main() in a program Tells other functions when to execute

Calls them

int main() -- Function Header{ -- Body inside

{ } -- Executable Statements

}

Page 6: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Comments

/* Comment */

Ignored by compiler Documents program

Page 7: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Preprocessor Command

#include <stdio.h>

Inserts code at that point Inserts the code before the compile

Provides interface with printf and scanf functions

Page 8: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

printf

Sends argument to monitor screen

printf(“Hello, Steve\n”);

Page 9: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Programming Style

What is wrong with style2.c? No Syntax Errors

Page 10: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Programming Style

Indentation Indent statements between { }

Comments Name, Date, Description of program

Meaningful identifiers “counties” instead of “x”

Page 11: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Questions

Give an example of a preprocessor

command.

What are two rules for good programming

style?

Page 12: The C Language 1/29/15. Quiz Take quiz 1 on Blackboard Over vim, linux, and Chapter 1.

Next

Data Types and Arithmetic Operations