-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope.c
More file actions
36 lines (31 loc) · 943 Bytes
/
scope.c
File metadata and controls
36 lines (31 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <errno.h>
/* global variable declaration */
int g;
int main() {
// The following example shows how local variables are used. Here all the variables a, b, and c are local to main() function:
int a, b;
int c;
// actual initialization
a = 10;
b = 20;
c = a + b;
printf ("value of a = %d, b = %d and c = %d\n", a, b, c);
// The following example shows how global variables are used.
/* local variable declaration */
//int a, b;
/* actual initialization */
//a = 10;
//b = 20;
//g = a + b;
//printf ("value of a = %d, b = %d and g = %d\n", a, b, g);
return 0;
}
// C - Scope Rules. (2012, June 10). Tutorials Point. Retrieved April 16, 2023, from https://www.tutorialspoint.com/cprogramming/c_scope_rules.htm