You are suggested to use the teaching servers hulk.soic.indiana.edu or tank.soic.indiana.edu for practicing C programs.
Example: a simple loop program : code
Something worthy further discussion:
overflow of int variable
When you declared a signed int variable, for example, in some old machine, it takes up 8 bytes.
[][][][][][][][] In this case, the first bit is used to indicate whether the digital you save in this variable is positive or negative.
0: positive1:negative
And the range of integal number it can hold is [255,-256].
So when you continue adding up to this variable, for example, add 1 to 255 (which is 01111111 in machine code). In mathematics, it will be 256,
but in machine code, it's 11111111, which turns out to be -256. "Overflow!" code
Make decision among multiple choices using if-else structure. For example, input score of some course and get the corresponding grade: A: 90-100 B: 75-89 C: 60-74 F: 0-59.
sample codeRead carefully C manual for the following functions in stdio.h & stdlib.hfopen fclosefwrite fread fputc fgetc fgets fscanf fprintfgetc getchar gets getline
Here is a sample program which allows you to open a file and write a sentence into it.Code
int min = &infin /* in real code, you could assign a very large number to min*/ for a in array /*array stores the numbers you input*/ if a < min min = a print min