lec5-c - ECE 175 The if, if-else, and switch block command...

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

View Full Document Right Arrow Icon
ECE 175
Background image of page 1

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

View Full DocumentRight Arrow Icon
The if, if-else, and switch block command for checking program conditions The use of the debugger (GDB) to debug your programs Compile with –g flag Load file to debugger with file Set breakpoints with break Run your program step by step using run,step,next,cont Display variables with print,watch and display Use and declaration of functions, setting arguments Intro to program design 05/13/09 ECE 175, Fall 2007 2
Background image of page 2
Basic components of a C program Declaration of variables (naming), available data types and their differences Assigning initial values to your variables Printing on the screen according to data type and desired format (data types, tabs, newlines, spaces) Scanning for input by the user, creating user prompts Reading and writing in files Writing flow control blocks using while, do-while, for, if, if-else, and switch statements Running and compiling your C program 05/13/09 ECE 175, Fall 2007 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Program design How to analyze a given programming assignment to elementary components Extensive use of the Debugger to check on the validity of your program We will run most of our programs step by step to check on the execution Declaration accessing, reading and writing arrays 05/13/09 ECE 175, Fall 2007 4
Background image of page 4
Problem statement: Write a C program that counts the characters, lines and words of a file. Check the validity of your program by using itself as an input (this is equivalent to the wc command in UNIX) 05/13/09 ECE 175, Fall 2007 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
Program analysis Input: a file that we want to process Output: number of words, lines and characters Algorithm design Initial condition: Read the file we want to process Character count: while loop , increase nchar variable
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/06/2008 for the course ECE 175 taught by Professor Grubbs during the Fall '08 term at University of Arizona- Tucson.

Page1 / 23

lec5-c - ECE 175 The if, if-else, and switch block command...

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

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