Skip to main content

Basics of C language

Basics of C language

C language is the most commonly used programming language. C language is invened by Dennis Ritchie. It is used in wide range of aaplications. Before C language there ware Assembly level language and Basic compiling programming language(BCPL). Assembly level language code is leanthy as compared to C language code, therefore C language is preffered over BCPL and Assembly level language.

Basic Structure of C language

Documentation Section
Link Section
Defination Section
Global Declaration Section
Main function Section
Subprogram Section


C program always starts with a include file. SYNTAX : #include filename where filename may be stdio.h, conio.h, math.h, string.h, etc. depending upon the operation to be performed in the program. Most commonly used is stdio.h, which stands for standard input output header file. math.h is used to perform mathematical operations in the program, similarly other header files are used to perform specific program in the program.


Mainly C language consists of function. Anything in C language which is followed by pair of parenthesis '()' is called as function. Ex. printf(____), scanf(____). main function starts with opening curly braces'{' and ends with closing curly braces'}'. These opening and closing curly braces is known as a block. And anything writter inside these block is called as function defination.

  main()                  //main function
    {                     //opening of block
  
     statement;           //function defination
  
    }                     //closing of block.
    


Simple program in C language.

  //Program to print Hello World.

#include <stdio.h>
int main()
{
    printf("Hello World.");
    return 0;
}

Output : Hello World.


If you want to learn more in C subricribe to these blog.

Comments

Popular posts from this blog

Loops in C programming.

Loops are very important concept in C language and any other programming language. Loops are important to convert the larger program to smaller ones. Loops are 'the sequence of statement which continues to execute until the desired condition is met.' There are 3 types of loops in C language : 1. for loop. 2. while loop. 3. do while loop. 1. for loop The syntax of for loop is " for(initialization;expression;increment/decrement)". For loop is also called as entry controlled loop , where we initialize statement, give condition, and update statement in a single line. The for loop statement will be executed until the condition evaluation is true. Whenever the condition fails the control skip the for loop. Flowchart of for loop. Simple program to print number from 1 to 10 using 'for loop'. #include <stdio.h> void main() { int i; for(i=0...

Arithmetic Operations in C language

Arithmetic operations are addition, subtraction, multiplication ,division and modulus. All these operations can be performed in the C programming using arithmetic operators. Arithmetic operators are ( + , - , * , / ,%).Using these operators we can perform different types of operations. Program To add two numbers. #include <stdio.h> int main() { int a,b,c; printf("Enter the value of a :"); scanf("%d",&a); printf("Enter the value of b :"); scanf("%d",&b); c=a+b; printf("Addition of a and b is %d.",c); return 0; } Output : Enter the value of a :5 Enter the value of b :2 Addition of a and b is 7. In these program the first line "#include <stdio.h>" is the header file which is used for basic input and output in the program."int main()" here ...