In C Programming For Beginners – Part 3, we met the following program which calculates the area of a square:
#include <stdio.h>
main() {int a, s; printf("Enter length of side: ");scanf("%d", &s); //store length in sa = s * s; //calculate area; store in aprintf("\nArea of square is %d\n", a);
}
Next, you must type the program to a file: you can name the file AreaOfSquare.c. It is recommended that you use .c for any file that contains a C program.
You must store your program as a text file. You can use Notepad or WordPad. You can use Word (or another word-processor) but be sure to save it as a text file.
For convenience, we assume that you have created a folder C:\CPrograms and will store your programs there.
Summary: we assume the Tiny C compiler has been installed in
C:\TinyC
and your program is stored in a file AreaOfSquare.c in the folder C:\CPrograms.
In the next article, we show how to compile and run the program.