Compiler and Environment Setup
Compilers: when you write any program in C Language then to run that program, you need to compile that program using a C compiler which converts your program into a language understandable by a computer. This is called machine language (i.e. binary format).The most frequently used and free available compiler is the GNU C/C++ compiler, otherwise, you can have compilers either from HP or Solaris if you have the respective operating systems.
Instillation on windows
To install GCC on Windows, you need to install MinGW. To install MinGW, go to the MinGW homepage, www.mingw.org, and follow the link to the MinGW download page. Download the latest version of the MinGW installation program, which should be named MinGW-.exe. While installing MinGW, at a minimum, you must install gcc-core, gcc-g++, binutils, and the MinGW runtime, but you may wish to install more. Add the bin subdirectory of your MinGW installation to your PATH environment variable, so that you can specify these tools on the command line by their simple names. After the installation is complete, you will be able to run gcc, g++, ar, ranlib, dlltool, and several other GNU tools from the Windows command line.
Program Structure
Before we study the basic building blocks of the C programming language, let us look at a bare minimum C program structure so that we can take it as a reference in the upcoming chapters;
Hello World Program
C Program basically has the following form:
a. Preprocessor Commands: These command tells the compiler to do preprocessing before doing actual compilation Eg:
#include
is a pre-processor command which tells a compiler to include stdio.h
file before going to actual compilation.b. Functions: Function is the main building block of any C program. Every program will have one or more function and there is one mandatory function which is called main( ) function.
c. Variables: Variables are used to hold numbers, strings, and complex data for manipulation.
d. Expressions: Expression combine variable or constant to create new values.
e. Statements: Expression, assignments, functions calls, or control flow statement which make up c programs.
f. Comments: Comments are used to give additional useful information inside a program. Eg: /*Hello world*/
g. C is a case sensitive programming language. It means in C Printf and printf have a different meanings.
h. C has a free form line structure, end of each C statement must be marked with a semicolon.
i. White spaces(i.e. tab space or spacebar) are ignored.
j. Statements can continue over multiple lines.
Share on Social Media