.png)
col
row 1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
#include <stdio.h>
#define ROWS 5
#define COLUMNS 5
int main() {
int i = 0;
while (i < ROWS) {
int j = 1;
while (j <= COLUMNS) {
printf("%d ", j);
j++;
}
printf("\n");
i++;
}
return 0;
}
struct pokemon {
int hp;
double weight
};
enum elemental_type { FIRE, WATER, GRASS, DARK };
printf, scanf, main...int add(int x, int y) {
return x + y;
}
int ... -> return type (what type should the result beadd -> the name of the function(int x, int y) -> the parameters, what sequence and type of input must be passed in?return -> evaluate the expression and return the resultadd(2, 5);
() after the name of the function means callint add required two integers).We can pass in variables too
// A simple function which accepts two integers (x, y),
// and returns the result (int) of adding them.
int add(int x, int y) {
return x + y;
}
int main(void) {
int year_born = 1994;
int age = 29;
add(year_born, age);
}
// A simple function which accepts two integers (x, y),
// and returns the result (int) of adding them.
int add(int x, int y) {
return x + y;
}
int main(void) {
int year_born = 1994;
int age = 29;
int current_year = add(year_born, age);
}
not a real thing in C, but a useful way to think about some types and roles of functions
shut_door
side effect?
result?
check_door_shut
side effect?
result?
void check_door_shut() {
}
Functions/procedures have to be defined before they care called
int add(int x, int y); at the top of your file to define the int add function for later use