Simple Program in C Language - First C Program
Here we will see, How to write first program in c language and how to compile and run first c program. In first program of c language, we will print simple "hello world" massage.
After learning the complete introduction of c language and features of c language, it is time to learn how to run first program in c.
Before executing a first program in c language you need to download and install Turbo C++ on your computer. There are many compiler available for c and c++ that you can use but mostly used compiler is Turbo C++.
You can download here, Turbo C++.
After Downloading and installing Turbo C++ on your computer, you will be able to write a first program in c.
Let's write a complete program that prints hello world to the screen.
To print hello world, Open c console i.e use turbo c++ and type simple code which is given below.
For example :
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("hello world");
getch();
}
Output: hello world
Let's understand the above code in detail.
Let's print hello world c program with c console i.e with Turbo c++ and see how to compile and run c program.
Output:
Press enter for back to the Turbo C++ console
After edit c program, We have to compile and run c program for displaying output.
After learning the complete introduction of c language and features of c language, it is time to learn how to run first program in c.
Before executing a first program in c language you need to download and install Turbo C++ on your computer. There are many compiler available for c and c++ that you can use but mostly used compiler is Turbo C++.
You can download here, Turbo C++.
After Downloading and installing Turbo C++ on your computer, you will be able to write a first program in c.
Let's write a complete program that prints hello world to the screen.
To print hello world, Open c console i.e use turbo c++ and type simple code which is given below.
For example :
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("hello world");
getch();
}
Output: hello world
Let's understand the above code in detail.
(1) #include<stdio.h>
It includes the standard input and output library functions. The printf() function is defined in <stdio.h> file.(2) #include<conio.h>
It includes the console input and output library functions. The getch() is defined in <conio.h> file.(3) void main()
In c, void is a return type which returns nothing and main() is a function in c language where program execution start. In other words, We can say that main() is function and it is the entry point of every programs in c.(4) clrscr() function
In c, Function clrscr() is used to clear the screen e.g suppose you execute different - different c program many times and do not use clrscr() function then the output of previous program will be add to the current program's output.(5) printf() function
It is used to print the data or massage on the console.(6) getch() function
It is used to hold the screen. Press enter or any key to release the screen.Let's print hello world c program with c console i.e with Turbo c++ and see how to compile and run c program.
Output:
Press enter for back to the Turbo C++ console
After edit c program, We have to compile and run c program for displaying output.
How to Compile C Program
There are 2 ways you can compile c program.
(1) By menu : Click compile menu and then choose compile sub menu to compile the c program.
(2) By shortcut key : Use Alt+F9 for compilation.
How to Run C Program
There are 2 ways you can run you c programs.
(1) By menu : Click on run menu and then choose run sub menu for run c program.
(2) By shortcut key : Use Clt+F9 for running c programs
Note: Clt+F9 key compile and run c program at the same time.
Read More:
How to Use Pointers in C.
What is Recursion in C Language.
Here we discussed, How to write a first C program and compilation and execution of Firs C programs with Turbo C++.
Read More:
How to Use Pointers in C.
What is Recursion in C Language.
Here we discussed, How to write a first C program and compilation and execution of Firs C programs with Turbo C++.
Hi, thanks for your blog, if you want to learn about programming languages like java, php, android app, embedded system etc. I think this training institute is the best one.
ReplyDeleteBest java training in coimbatore
Android training in coimbatore
Networking training in coimbatore
Get the best update of the Scope of Hadoop Technology and job opportunities for it from the best software training institute in Chennai, Infycle Technologies. Call +91-7504633633, +91-7502633633 to get the amazing offers and free demo for having Big Data hadoop training in Chennai.
ReplyDelete