-->

Automatic (also called local variables):

in turbo c++
-----------------------------------------------------------------------------
//program to understand local variable .
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
void function();
int main()
{
    function();//function calling
   getch();
    return 0;
}
void function()//function body line
{

    auto int a=4;//local variable, it can not be accessed from outsides. we can also use keyword auto.
    float b=7.89;//local variable// can not be accessed from outsides
    printf("a=%d,b=%f",a,b);//printing value
}







---------------------------------------------------------------------
in codeblocks
--------------------------------------------------------------------
//program to understand local variable .
#include <stdio.h>
#include <stdlib.h>
void function();
int main()
{
    function();//function calling
    return 0;
}
void function()//function body line
{

    auto int a=4;//local variable, it can not be accessed from outsides. we can also use keyword auto.
    float b=7.89;//local variable// can not be accessed from outsides
    printf("a=%d,b=%f",a,b);//printing value
}

No comments:

Post a Comment