google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a c program to illustrate the scope of variables - 2nd puc computer science

Write a c program to illustrate the scope of variables

write a c program to illustrate the scope of variables,local and global variable in c, scope of variable example

Write a c program to illustrate the scope of variables

#include<stdio.h>

#include<conio.h>

void p();

void q();

int a=5;

void main()

{

int a=10;

{

int a=15;

clrscr();

printf("In block inside main() function a=%d\n",a);

}

printf("In main() function a=%d\n",a);

printf("In main: ::a=%d\n",a);

p();

q();

getch();

}

void p()

{

printf("in p(): a=%d\n",a);

}

void q()

{

int a=20;

printf("in q(): a=%d\n",a);

}

Output:

In block inside main() function a=15

In main() function a=10                                                        

In main: ::a=10                                                                

in p(): a=5                                                                    

in q(): a=20 
Write a c program to illustrate the scope of variables Write a c program to illustrate the scope of variables Reviewed by Vision Academy on December 13, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.