First C Program, How Program works.

-- Leave a Comment
Here is a simple program of c. Try not to learn what is that just understand and looks how program goes on. For learning go through program and come back to understand. as your mind will make some ideas from first view.

1. /* Simple Basic Program */
2. #include<stdio.h>
3. #include<conio.h>
4. main()
5. {
6. printf("Hello Sansar!");
7. getch();
8. }

The first line is a comment you can write whatever you want inside /* and */ it wont affect in program.
The Second 2 lines are header files they call library functions to work in the program. stdio.h is For Standard Input/Output library. You must have that header to use printf() function.
conio.h is called to use getch() function in program.
Line no 4 define main function. The function main will be called first when program starts. all the commands on main function are covered inside { and } braces.
line no 6 printf("Hello Sansar!"); will print in the screen. printf is a library function to print out. every statement on c program should ends with ;.
getch() function hold the screen till some character are inserted from keyboard. however modern compiler did not need this while programming.

How a program should be written?

  • Program should be in same order that programmer want it to be executed.
  • tabs and spaces can be added as needed for better looks and easy for debugging.
  • Remember all statements are in small case letter. C is case sensitive.
  • C is called free-form language. as there is no any rule for position where statement should be written.
  • Every C statement must end with ;. ; is a terminator for all statement.


This is basic of all so next we will go to if else else if condition. Comment if need any helps out there.

Hello This is Sagar Devkota. Studying Bachelor of Software Engineering at Pokhara University. I know something about Linux, Android, Java, Nodejs, Unity3D and 3 dots :)

0 comments:

Post a Comment