STARTING WITH C
There are two ways of starting with C :-
* Open MS-DOS prompt.
* Type TC and press ENTER.
* Now you have entered the huge world of C programming.
The next altenative is :
* Open the folder which contains C files.
* Double-click on the TC icon.
Basic terminology
Constants - Constants are those individual units whose value does not change during program execution. In other words, their value remains constant.For ex.- number 5
Variables - Variables are those units whose value can change during program execution. For ex.- initially we say that a = 5 and b = 0. then we say that b = a + 2 . Now b's value will be 7.
Operators - Operators are those directions which are used by the programmer to alter the variables' value. In the above example '+' is an operator which is used to change b's value.However, there are more operators which are used for some other processes as well.
Functions - Functions can be defined as a group of statements which make use of variables, operators, etc. for completing a particular task. For example, printf is a function used in C to show output on the monitor.
A Simple Program
This program is used to display "this is easy !!!" on the monitor. Before beginning with the program, please note that every program contains a main function.
#include<stdio.h>
#include<conio.h>
void main()
{
printf("This is easy !!!");
getch();
}
The first two lines of the program tell the compiler to 'include' the header files. Header files are those files which are provided in C for user assistance. They contain some pre-defined functions. The 'main' is succeded by a bracket which tells the compiler that main is a function. Then the { brace tells it that the definition of the function begins. Since printf is also a function (although pre-defined) it is also succedded by a bracket. The bracket contains the sentence which is to be displayed. Please note " sign before and after the sentence. It tells the compiler where the sentence begins and where it ends. The semi-colon ; after the printf statement is necessary since it shows that the command is finished. Getch() is another function which implies that a key is to be pressed by the user at the time of execution. Lastly, the } brace tells that the main function has ended now.
Hence the program displays the sentence "this is easy !!!" and terminates as soon as the user presses a key.
Post Comments