Today i am here to explain a simple Program in C for beginners. For for that you should have a C language Compiler Like Turbo C.. You can Download it From here Click Here To download Turbo C!!! After Download and finishing installation Turbo c program goto C:\TC\BIN in your PC.This is the default location where you can find turbo c compiler and editor. find a tc.exe file and open it.
now a blue screen with a cursor blinking on it showed. you can start to write your first c program.
first of all you have to define header files. header files contains definitions of all functions which we use in our program. first i am writing a program "hello world" , then i will try to explain how it works.
#include
#include
void main(void)
{
clrscr();
printf("HELLO WORLD");
getch();
}
this program will give the output "HELLO WORLD"But without " " Inverted Commas..
Now lets discuss this program
the first two lines
"
#include
#include
"
are header files. conio.h is a short form of console input output.header and stdio.h is a short of standard input output.header. these two files contains definitions of functions that we use in our program.
the third line is a function. every c program must have at least one function that is main function.
"void main(void)"
function return somethings but in main function void is showing that this function is not returning anything.
then you see { } curly braces. this defines body of your program. whatever you have to write, you mus write in between these braces.
then we use another function clrscr()
is a short of clear screen and parenthesis showing that it is a function. by using this function you would be able to clear the previous outputs from the screen before you run another program.
then the line " printf("HELLO WORLD"); "
printf is function use to print whatever you want on the screen. anything in the inverted commas will display on screen as it is by using this function.
how can we forget ; semicolon.
it is called line terminator. a semicolon shows that a statement is completed.
then next and final line and of course another function
getch();
your program is also complete without this function but your output can not stop on the screen without this function. if you don't use it and run the program your output will come on screen and vanished as it is not appeared.
Tthat all for this tutorial. hope you will find it useful for you...
now a blue screen with a cursor blinking on it showed. you can start to write your first c program.
first of all you have to define header files. header files contains definitions of all functions which we use in our program. first i am writing a program "hello world" , then i will try to explain how it works.
#include
#include
void main(void)
{
clrscr();
printf("HELLO WORLD");
getch();
}
this program will give the output "HELLO WORLD"But without " " Inverted Commas..
Now lets discuss this program
the first two lines
"
#include
#include
"
are header files. conio.h is a short form of console input output.header and stdio.h is a short of standard input output.header. these two files contains definitions of functions that we use in our program.
the third line is a function. every c program must have at least one function that is main function.
"void main(void)"
function return somethings but in main function void is showing that this function is not returning anything.
then you see { } curly braces. this defines body of your program. whatever you have to write, you mus write in between these braces.
then we use another function clrscr()
is a short of clear screen and parenthesis showing that it is a function. by using this function you would be able to clear the previous outputs from the screen before you run another program.
then the line " printf("HELLO WORLD"); "
printf is function use to print whatever you want on the screen. anything in the inverted commas will display on screen as it is by using this function.
how can we forget ; semicolon.
it is called line terminator. a semicolon shows that a statement is completed.
then next and final line and of course another function
getch();
your program is also complete without this function but your output can not stop on the screen without this function. if you don't use it and run the program your output will come on screen and vanished as it is not appeared.
Tthat all for this tutorial. hope you will find it useful for you...
Yeah...It's useful .
ReplyDeletesilverlight c#, javascript, ms sql
Thanks!
Regards!
hi very useful post to begin c language.. expecting continuation of this tutorial.. :) C Tutorial For Beginners
ReplyDelete