Programming for Beginning with C Programming language

Programming languages or concepts

Beginning with C programming language.


1] Structure of C:-
       It means any program can be written in this structure only we can not used other structure for C program.

The Structure of a C program is a follow:-


        #include<studio.h>
         int main()
        {
             int a=10;
             printf ("%d",a);
              return 0;
         }

The Components of the above Structure:-


1) Header file :-


        The first  Comment is the inclusion of the header file in a C program. A header file is a file with .h extension which contains C function declarations.functions are predefine in the Header file.

Some of the header files:-


1. stdlib.h:-.     Define numeric conversion for pseudo random memory allocation.

2. studio.h:-.    Define  input and output function in studio.h function

3. string.h:-.     Define string handling functions.

4. math.h :-.     Define common mathematical functions.

Syntax to include header file in program:- 


       #include<Header file>

Ex. 

        #include<studio.h>


2) main method declaration :main():-


     The next part of a C program to declared the main() function.

 Syntax to main():

           int main()

           { ------


            }


3) Variable declaration:- 


  A variable is nothing but a name given to a storage area that our programs can manipulate.


We can not used a variable without declaration in program.

The variable are declared before any operation in the function.

Example:

                    int main()

                    {

                       int a;.     // Declaration.

                     }


4) Body:- 


In the filed you can implement your logic of program for getting expected result.

It refers to the operation that are performed in the function it can be anything like searching, sorting, printing etc.

Example:-

                     int main()

                     {

                         int a;

                         printf("%d",a);

                       }


5) Return Statement:-


  The return function statement refers to the returning of the values from a function.

A Return Statement can also return a value to the calling function.

Return value depends on return type of the function.

Ex. 

                int main()

                {

                    int a;

                    printf("%d",a);

                    return 0;

                  }


Write a Simple C program:

 

                   #include<studio.h>

                    int main(void)

                    {

                         printf("saurabh1999.blogspot");

                         return 0;

                     }


Recommended for you:-






close