Home > C Tutorials > Introduction to C Programming

Introduction to C Programming

C language has been called as Father of all languages. If a programmers knows C Programming then he/she can work on any programming language. This articles aims to introduce programmers to the C language.

Structure of a C Program
Example

/*A simple C example program*/
#include "stdio.h"
void main() {
	printf(”Hello World”);
}

The output of the above program would be.

Hello World

Now we will understand the code written

/*A simple C example program*/

Any sentence or word starting with /* and ending with */ are called comments. While compiling this program the C Compiler ignored this line as this comments are meant for better understanding of the program. Though comments are not compulsory but it is recommended for good programmers to write comments as it is becomes useful in live environment.

The next line looks like this:

#include "stdio.h"

Any statement starting with # in C are called preprocessor directive. The word inside the double quotes are called header file, All header files have extension .h in C language, there are different header files used while writing C programs here we have used stdio.h which is required to do the work of Input / Output operation. The preprocessor directives should not end with a semicolon because preprocessors are messages to the compiler.

Your email:

 


The next line reads:

void main()

main function represents the start of program in C programs. Every function in C should be postfix with (), any value that need to be passed to the function is passed as an argument to the function. void indicates that this function will not return any value.

The next line is a

     {

This is called the left brace and marks the opening or beginning of a function, here in our case main.

The next line is a

	printf(“Hello World”);

This statement displays the string Hello World on screen. Here printf() function is responsible for displaying Hello World on the screen. Here we are ending the statement with semicolon. This is required as every statement in C programming should end with semicolon(;) as this marks the end of statement.

The last line is a

	}

This marks the end of the function main. Since main is the only function in the program it also marks the end of our program.

Your email:

 

Source:
Introduction To C Programming


Custom Search

Popular Articles:

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • IndianPad
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • RSS
  • Technorati
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • Reddit
  • Add to favorites
  • PDF
  • Twitter
Categories: C Tutorials Tags:
  1. SeamlessDev
    August 8th, 2008 at 12:39 | #1

    Great write-up! I agree that C language is still important. While not always used for programming (I’m a PHP & .Net person), it’s a great language to know and understand as it helps to understand the other programming languages.

    SeamlessDev Staff,
    Seamless Development

  1. No trackbacks yet.