• Basic of c programming

    Introduction of C Programming 

    In computer science C is a programming language which is the mother language of all programming languages like C++, C# (C-Sharp), Java etc. This is developed to create Unix Operating System which is the world’s strongest OS. Dennis M.Ritchie developed this language in 1972 at the Bell Laboratories. 


     Why C is mother language of programming?

    It is a good and attractive question and every programmer should know the answer. C language is easy to learn and use, structured, efficient, powerful in compare to COBOL and FORTRAN. Most of the languages are developed with the help of this language and the concepts are same. Every programmer or software developer first learns c language then other programming because it plays a key role and gives guidance. If you learned this language and command on it then you can also learn others very easily because most of the topic, or functions line variable, constant, operator, loop, array, function, structure etc are same. 


    Software needed for c programs? 

    To run C programs you have to install TC/Turboc Software in your system and open it. You will get a blue screen, now write the code then compile and execute. 

    How to Compile C programs? 

    To compile c programs press ALT+f9 

    How to Run C programs?

    Press CTRL+f9 

     A Simple program of C: 

     #include<stdio.h>
    void main()
     {
     printf("hello world");
     }
     getch();

    Explanation of the above given program:

    #include<stdio.h> is the header file where stdio means standard input/ output
    void is used for no return, it means nothing but it can't compare to zero (0).
    main() in the function which is the entry point of the program.
    printf for displaying the message
    getch() for stay the screen to get input


    List of some topics which you have to know and study in each and every programming language.

    1. Variable and Constant
    2. Data Type
    3. Operator
    4. Loop
    5. Array
    6. Function
    7. Input/Output
    8. Structure

    What is variable and constant?
    Variable is the fixed value where as constant is unfixed value. The value of the variable is changeable according to the program. Ex:
    variable- a, b, x, y, z etc.
    constant- 5, 2, 10, 25 etc.

    You will get the both terms in every programming languages but there are no changing in the concept so remember it for ever.

    Data Type:

    Data type define the type of data you have to use in your program. It helps to determine about data and its storage such as it helps to know that the given data is character or integer or float or string etc.

    Syntax:

    datatype variable name;

    Types of data type:

    There are two types of data types which are given below-

    i) Fundamental Data Type  
    Fundamental Data Type are the data type which not depend or other data type but many data types of programming depend on it such as int, char and  float.

    Data Type       Bytes

    int                    1
    char                 2
    float                 4



     ii) Derived data Type:

    Derives data types are such type of data types which depends on fundamental data types such as small int, big int, double float etc. 

    Note:  There are some other data types which are user defined but used in other programming languages which are object oriented r which has class concept. Array, class and interface are the examples of those data types. C language has not concept of class so you can't use these data types.
     

    Operator:
    Operator are special symbols used in programs to perform certain operations like addition, multiplication, assign values, compare operands etc.
    Examples:
    Unary Operator :-
    This operator is performed on only one operand such as a++, ++a etc.

    Binary Operator:
    This operator is performed on two operands such as a+b, a-b, a*b etc.

    Ternary operator:- Ternary operator also perform operation on two operands but in short form such as (a>b)?a:b;

    Apart from the given types and examples we can also study the operator in many forms such as arithmetic operator, assignment operator, relational operator and logical operator, etc.

    Arithmetic Operator:-
    Arithmetic operator are used to perform arithmetic operation (addition, substraction, multiplication, division, modulo) on two operands such as-
    A+B, A-B, A*B, A/B, A%B

    On the above given example there are five operators are used in arithmetic operator which are as well-
    +  :- Used to add two operands
    -   :- Used to substract two operands
    *   :- Used to multiply two operands
    /    :- Used to divide two operands
    %  :- Used to get the reminder

    Assignment Operator:-
    This operator is used to assign a value to the operator to use in the program. The symbol = (equals to) is used between two operands such as A=B; or A=5;

    Relational Operator:-
    As its name suggest it is used to define the relation between two operands or also to compare the operands to get the result that which is greater, smaller etc. Details with symbol are given below-

    A>B;     :-  A is greater than B
    A>B;     :-  A is smaller than B
    A>=B;   :-  A is greater than or equal to B
    A<=B;   :-  A is smaller or equal to B
    A=B;     :-  A is equal to B

    Note:- When we compare two operands then there may be three situations such as one operand may be greater or smaller or equal.

    Logical Operator:-

    Logical operator is used to apply logic on conditions of the programs to clearing that the given condition is true or false. It is also also helping in decision making of program.
    There are three types of logical operator in every programming language which are given below-
    AND  &
    OR     ||
    NOT  !


    1. If both condition is true then AND operator works otherwise you will get an error.
    2. If any one of the conditions is true then the program will run
    3. If the given condition not matched to the condition then it will run.








    No comments:

    Post a Comment

    Home

    About Us

    Contact Us