C Basics

The Structure of C Programs

User Rating:  / 4
PoorBest 

As C is procedural language building blocks of C program are functions. Every function is well-designed program and serves a specific purpose. Execution of C program is sequential. Standard functions are available in library which can be included in every program. Every C program must define at least one function of its own, with the special name main (): this is the first function invoked when the program starts. The main () function is the program's top level of control, and can call other functions as subroutines.

First Sample C Program. helloworld.c (It prints Hello World to Output Screen)


#include <stdio.h> // Preprocessor Directive
int main() // Main Function
{
   printf(“Hello World!”);
   return 0; // Return 0
}

Output: -

Hello World!

The prototypes of standard library functions are found in standard header files. Because the header file stdio.h contains the prototype of the printf( ) function, the preprocessor directive #include declares the function indirectly by directing the compiler's preprocessor to insert the contents of that file.

printf() simply prints whatever written between “” (double quotes) to output screen.

At this point don’t worry about header files, printf function, return type and all. We will cover each of these in details in subsequent chapters.

 

 
 
 

                                                                                          About Us  ||  Contact Us  ||  Terms & Conditions  ||  Privacy Policy 

Referral Banners