How to Program in C Language
By rajkishor09
You might be thinking that you have learnt lot about C language background and now eagerly want to write your first program in C. To do so first of all you need a C compiler, I have been using Turbo C++ compiler for this purpose. Why Turbo C++ compiler why not Turbo C compiler? Because Turbo C++ compiler supports both C & C++ program and if you want to learn C++, you don’t need to change your compiler. One more thing, Turbo C++ compiler provides mouse support which Turbo C compiler doesn’t.
I assume that you have installed C compiler in your PC and now want to try your first program. Here is an example of your first C program which has been developed using Turbo C++ compiler.
How to Write Program in C
#include <stdio.h>
void main()
{
printf("Welcome to C");
}How to Compile and Run C Program
Just type the above line in the C editor and press Alt + F9 to compile that program. If there is any mistakes, it will show “Error” message otherwise it will show “Success” message. Now press Ctrl + F9 to run compiled program and you will see similar output. If you cannot see anything then press Alt + F5 to see output window.
Program Output
how to program with c, an explanation
Let’s understand each and every line of this program. The very first line #include <stdio.h> tells the compiler to include a header file “stdio.h” in the program. Header file in C is nothing but collection of various functions. Here we are using "printf()" library function from"stdio.h" header file. The next line is "void main()" which is the beginning of the program. Every program must have a "main()" because program starts execution from this function (read more about main function here). But what does the keyword void means before the main(). This means that main function will not return any value to the compiler. I know this is tough to understand now; these things will be discussed in detailed in function page.
The curly open and close braces { } defines the scope of the “main()” function means “main()” function’s boundaries. The line between curly braces printf("Hello, World!"); is the one of function defined in stdio.h whose job is to print message specified in double quotation. At the end of the line there is a semicolon (;) which is the end of that statement. C statements always end with a semicolon (;).
One thing you should keep in your mind that in C program, instructions declared in “main()”, are executed from top to bottom. To understand it better let’s extend the above program.
How to program in C books
![]() | Amazon Price: $49.99 List Price: $140.00 |
![]() | Amazon Price: $82.00 List Price: $137.00 |
![]() | Amazon Price: $49.00 List Price: $123.00 |
![]() | Amazon Price: $45.00 List Price: $115.00 |
How to write program in c
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Welcome to C. ");
printf("C is a Programming Language. ");
printf("Hello! How are you?");
getch();
}C Program Output
how to program with c, an extended explanation
The top two lines include two header files “stdio.h” and “conio.h” respectively. The “stdio.h” header file contains “printf()” and “conio.h” file contains “clrscr()” and “getch()”. The “clrscr()” function clears the output screen, means any output shown by previously run program will be erased and that is why we always put them at the beginning. Next is three “printf()” statements which will print three different messages. The “getch()” waits for a keyboard input and if we press any key on keyboard the program exits. So we don’t need to press Alt + F5 to see the output as we did in above program.
The uses of “getch()” function will be discussed later in detail.
How to Program in C Language Poll.
Did this help you to write your first C Program?
See results without votingProgramming in C tutorials links
- The C Programming Language - Brief History
Before we start any complex program in C, we must understand what really C is, how it came into existence and how it differs from other languages of that time. In this tutorial I will try to talk about these... - C Programming Lesson - Data Types in C Language
A programming language is proposed to help programmer to process certain kinds of data and to provide useful output. The task of data processing is accomplished by executing series of commands called... - C Programming Lesson - Function in C
A function in C language is a block of code that performs a specific task. It has a name and it is reusable i.e. it can be executed from as many different parts in a C Program as required. It also ... - C Programming Lesson - Types of Function
In my previous c programming tutorial I tried to explain what the function, its advantages is and how to declare a C function. And I told you that there are five types of functions and they are: ... - C Programming Lesson - Arrays
An array in C language is a collection of similar data-type, means an array can hold value of a particular data type for which it has been declared. Arrays can be created from any of the C data-types int,... - 2 Dimensional Array in C Programming Language
We know how to work with an array (1D array) having one dimension. In C language it is possible to have more than one dimension in an array. In this tutorial we are going to learn how we can use two... - C Programming Lesson - Basic Virtual Keyboard Application
To accomplish this task you dont need to buy any expensive software or hardware, only a little knowledge of C program will do and you can build your own musical keyboard software. Before we begin you... - C Programming Lesson - File Copy Program in C
Today we are going to learn a simple file copy program in C language. As I said this is a simple file copy program so you should not expect its output like DOS copy command has. Ok lets start. The main... - C Programming Lesson - Multidimensional array (3D Array)
C allows array of two or more dimensions and maximum numbers of dimension a C program can have is depend on the compiler we are using. Generally, an array having one dimension is called 1D array, array...
Useful Links
- What is LAN (Local Area Network) ?
LAN is acronyms of Local Area Network. LAN is required everywhere, whether it is office home or somewhere else. LAN is a small computer network (small version of internet) covering a small area like home,... - Hack Google for Better Search Result
Google, on internet, by far is the most popular search engine which is used by about 80 percent of total internet users. Googles this popularity is because of excellent search results with extensive range... - Extend Your Computers Life
A computer is a complex electronic device which we own proudly. But to remain its proud owner we need to take care of it. To extend life of computer, it must be regularly examined as we do for various...
Comments
how we understand program
it is the most interesting site,which gives lots of information rgarding computer
Another hello world, but there are quite a few links. ;-)
i just love dis site
GOOD
Its very usefull hub.or we can call it as Knowledge Repository.
eoooww!!!!mor power guys!!!god bless!b careful??..
its easy to understand
this is useful for our study and proggramming
ITS EASY FOR BEGINERS TO KNOW ABT :C"
easy way to develop software skills this procedure
very easy to understand.....thanks to hubpages
yeah its easy 2 undrstnd...!
Verry useful site,thanx the creater
Easy to understand.....I like it.
hi my prof asked me to do a program the out put is like this;
0
0
0
0
0
0
0
0
0
0
[1] Bottom
[2] Top
if u press 1 the output will be like this
0
0
0
0
0
0
0
0
0
1
[1] Bottom
[2] Top
then if u press 2
another out put will be like this
1
0
0
0
0
0
0
0
1
it is continues until it will be like this
1
1
1
1
1
1
1
1
1
1
thank you it helps me :)
my output is more than one page long but i can see only one the last page ..how to view the other pages of my output
Cool i am unable to run my program because i have written studio.h instead of stdio.h .After watching this i have run my program
very usefull site
nice.. this site could help me on my course (information technology) specially the programming languages
God bless you rajkishor09
guys can you help me create a program that can compute for the percentage of a grade pleeeaaseee!.. thanks
yeh i think it is the best language that i learn
thanks its too easy to understand
Thankssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
Great Hub ..... I really think C or C++ are some of the first languages to learn. Initially I started working with C book and then moved to C++. By the time I started learning Java, it was really easy to apply what I had already learned and quickly pick it up.








brad4l 3 years ago
Cool Hub :)I really think C or C++ are some of the best first languages to learn. I started working through a C book and then switched to C++. By the time I started learning Java, it was really easy to apply what I had already learned to Java and quickly pick it up.