Monday 16 November 2015

C proagramming Hello World

C hello world program

c programming language code to print hello world. This program prints hello world,printf library function is used to display text on screen, '\n' places cursor on the beginning of next line, stdio.h header file contains declaration of printf function. The code will work on all operating systems may be its Linux, Mac or any other and compilers. To learn a programming language you must start writing programs in it and may be your first c code while learning programming.

 

#include <stdio.h>
#include <stdlib.h>

int main()
{

printf("Hello world!\n");

return 0;
}


Output

Sunday 8 November 2015

Definition of variable in C

Definition of variable in C programming language:


A variable is named location of data. In other word we can variable is container of data.

 

In real world you have used various type containers for specific purpose.For example you have used suitcase to store clothes, match box to store match sticks etc. In the same way variables of different data type is used to store different types of data. For example integer variables are used to store integers char variables is used to store characters etc.On the basis of how many data a variable will store, we can categorize the all c variable in three groups.

  • (a)Variables which can store only one data at time. Example: integer variables, char variables, pointer variables etc.

    (b)Variables which can store more than one data of similar type at a time. Example: array variables

    (c) Variables, which can store more than one value of dissimilar type at a time. Example: structure or union variables.

    • Properties of variable in c:
    Every variable in c have three most fundamental attributes. They are:

    1. Name

    2. Value

    3. Address

    • Name of a variable:
    Every variable in c has its own name. A variable without any name is name is not possible in c.Most important properties of variables name are its unique names.Not two variables in c can have same name with same visibility. For example:


    #include<stdio.h>

    int main(){

    auto int a=5;

    static int a=10;

    printf("%d",a);

    return 0;

    }


    Output: compilation error


    But it is possible that two variable with same name but different visibility.In this case variable name can access only that variable which is more local. In c there is not any way to access global variable if any local variable is present of same name. For example:



    • #include<stdio.h>

    int a=50;

    int main(){

    int a=10;

    printf("%d",a);

    return 0;

    }


    Output: 10



    • #include<stdio.h>


    int main(){

    int a=10;

    {

    a+=5;

    int a=20;

    a+=10;

    printf(“%d”,a);

    printf(“%d”,a);

    return 0;

    }



    Output: 30 15

     

    Note: In c any name is called identifier. This name can be variable name, function name, enum constant name, micro constant name, goto label name, any other data type name like structure, union, enum names or typed name.

Monday 2 November 2015

What is Computer ?

The word "Computer" comes from the word "compute" which means "to calculate". Computer is an electronic device that manipulates information, or data.It has ability to store,retrieve and process data.You probably already know that you can use a computer to type documents,send email,play games,and browse the web.you can also use it to edit or create spreadsheets,presentations and even videos.

 

Fig:Computer