Day 7
- Reading: Read Chapter 8 by Tuesday
- Lab 4 is due at beginning of lab next Tuesday
- Midterm and Lab Quiz today
- Project 3 is assigned
- Lecture Topics
- Declarations and initialization
int a = 5, b = 3, c;
Function Prototypes
#include <stdio.h>
void doSomething(void);
int isSomethingTrue(char);
int main(void)
{
char letter = 'b';
if (isSomethingTrue(letter)) {
doSomething();
}
return 0;
}
void doSomething(void)
{
printf("This function does something cool.");
}
int isSomethingTrue(char aVariable)
{
return aVariable == 'a';
}
Nested loops
- Example: Write a function that prints an asterisks right triangle of base width n, where n is given as a parameter.
See the example below
*
**
***
****
*****
Example: Do the same as above but with a for loop
see solutions here