90 likes | 263 Views
Recitation September 12 , 2014. Attendance word: whisk Particularly if you weren’t at discussion last week! New webpage: http:// enee150section0101.weebly.com / Office hours: 12:30-1:30 , Mondays and Wednesdays By appointment. Announcements. Homework 1 Due: Monday, September 15 th
E N D
Attendance word: whisk • Particularly if you weren’t at discussion last week! • New webpage: • http://enee150section0101.weebly.com/ • Office hours: • 12:30-1:30, Mondays and Wednesdays • By appointment Announcements
Homework 1 Due: Monday, September 15th • Email me early!! • Submit it as a zip file with a separate file for each problem: • Sample command: zip hw1.zip problem1.c problem2.c problem3.c Homework 1
Improves clarity and readability • Group functions with a similar purpose together (believe me, it makes them easier to find!) • To compile: • gccmain.csupporting.cdefinitions.h Separate Files
Pre-declaration of a function: • Takes place in a header file or above “main” • Ex. intfunction_name(int,int); • Calling the function inside of another function: • Omit the variable types and insert the variable to be passed in. • Ex. a=function_name(b,c); • Writing a function: • Can be written in a separate file or underneath main. • Include return and input variable types and names. • Ex. intfunction_name(int first, int second) { //Function code return 0; } Functional Decomposition
Tips for creating functions: • Break the problem into the tasks that need to be completed. • Use hierarchical decomposition • Check each function as you go. Functional Decomposition
fprintf • fprintf(outfile, “Output=%d”, output); • fscanf • fscanf(infile, “%c”, in_character); • getc(FILE *) • putc(char, FILE *) • Similar to printf, scanf, getchar, and putchar • EOF I/O Function