Saturday, September 12, 2020

const variable - do not have hard coded numbers in more than one place (hard to maintain, often source of bugs)

 #include <stdio.h>


const int N = 3;    //make scope global; capital denotes constant


int main(void)

{

int scores[3];

scores[0]=72;

scores[1]=73;

scores[2]=33;


printf("average: i%\n", (scores[0]+scores[1]+scores[2])/N );

}



cs50, lec2