Skip to main content

How to learn c programming concept easily in simple and fast way?

 C Programming concept.

 

Anything in structured format is easy to understand. C is a structured language. We can easily debug, test and maintain the program by learning the structure.


Structure Of a C Program:


                         Include header file section
                      Global declaration section
                      main()
                        {
                            Declaration part
                            Executable part
                        }
                      User-Defined function
                        {
                            Statements
                        }

  • When we use function, variables and constant in program, we may need function definition so we use Header files. (use #include and extend with .h)
  • In Global Declaration section we can declare variables which are used in more than one function.
  • The execution of the program begins in the function main().
  • Initialization and declaration of variable in the executable part is done in Declaration part.
  • Executable part contain set of statement enclosed with braces.
  • The function defined by the user is called User Defined function.


SAMPLE PROGRAM:


Write a C program to add two numbers.

 #include<stdio.h>      /* standard input and output, to get input and show output */

 void main()                  /* function returning value will be null */
  {
   int a,b,s;               /* declaring integer variable , a and b  for two num, s for sum */         
   printf("enter the 2 num:");     /* to print the two numbers in output screen */
   scanf("%d%d",&a,&b);    /* accept input, %d to read integer, & is used to place the read value in variable */
   s=a+b;              /* arithmatic operation to add */
   printf("sum=%d",s);  /* to print arithmetic result  */
   getch();           /* used to hold output screen until user gives any type of input */
   }

 Output:
              Enter two num: 5
                                        6
                             Sum=11

   

In following days we will discuss more program in detail. If you like to learn more just follow me regularly. If you have any question to ask mention below in comment.Thank you......


Comments