Saturday, September 26, 2015

Hello program in C or First program in C

Now, after learning and understanding some basic concepts of the C programming we are going to write our first program of C. In this program we will combine variables, constants and keywords to make instructions. We will also look at the basic schema of a C program. In this program we will print "hello world" text.

#include<< stdio.h>>
#include<< conio.h>>
void main()
{
printf("hello world");
getch();
}

This is the first program of C.

In the first line we have defined a preprocessor (#). Which processes source code before code is passed to the compiler. In depth we will learn about the C preprocessor later.

Here, stdio.h (standard input output header file) is used for printf() function definition. printf() is used to print text.
conio.h file is used for getch() function definition.

main() is a function. A set of statement is known as function.
A function must always return a value. Here we have used void means this main() function will not return anything. If we want to return a integer value then we should use int on the place of void.

Important rules----
1.) Every statement should be separated by other statements.
2.) Every statement should be ends with ;.
3.) All statements should be written in small case letter.
4.) All statements must be written in same order in which we want to execute them.

3 comments:

  1. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
    website: geeksforgeeks.org

    ReplyDelete
  2. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
    website: geeksforgeeks.org

    ReplyDelete
  3. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
    website: geeksforgeeks.org

    ReplyDelete