Writing your first C Program
There are some basic rules those are to be remembered before writing your first C Program
For easy start with C Programming we will need an IDE . We are using Turboc3. It can be downloaded from https://developerinsider.co/download-turbo-c-for-windows-7-8-8-1-and-windows-10-32-64-bit-full-screen/ or by Searching on Google like ‘ Turboc for <Your Operating System>
Initial Screen for Turboc3, You can Create a New File from File Menu.
- C is an case sensitive language, so that printf() is not same as Printf() here.
- Most part of the C Program is to be written in Lower Case.
- Execution of any C Program begins with main() (here () is called function)
- Each C Program must have only and only one main() (main function)
- void is written before main(). void indicates that this main function is returning nothing. (Concept of return value will be discussed later in our blog)
- Each statement in C Language ends with ;
- main() is not a statement so no ; after main()
void main()
{
.... here your program will be written
}
- To display any content in Output Screen we have to use either printf() or puts().
- As printf() is a function we have to include Library (Header File) to detect the function (In some IDE it is optional)
- We can include library using #include<……>
- clrscr() is the function that clears the Output Screen So mostly it is written at first in main()
- getch() is a function to get any character input, but here we will use it to pause the screen, so it is written at last.
- clrscr() and getch() are defined in conio.h header file (Console Input Output)
- printf(),puts() are defined in stdio.h header file. (Standard Input Output)
- \n is used to start a new line in Output Screen
- Same way \t is used for Tab
- \n and \t are called Back Slash Characters (We will discuss more in future)
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Welcome To C Programming");
printf("\nC is Procedure Oriented Language");
printf("\n\tIt is easy to Learn");
getch();
}
To Execute the Program (To get Output) you have to compile the program using ALT+F9 and Run Program using Ctrl + F9