-
Notifications
You must be signed in to change notification settings - Fork 0
/
Functions.c
67 lines (46 loc) · 861 Bytes
/
Functions.c
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
int sq(int num); /* declaration */
int sum(int a, int b);
int global = 0;
void sayhello();
int main(){
//sq function
int x,res;
x= 5;
res = sq(x);
printf("%d Squared %d \n",x,res);
//sum with multi paramter function
int f,s,re;
f = 12;
s = 3;
re = sum(f,s);
printf("%d + %d = %d \n",f,s,re);
// Varibal scope
int local1,local2;
local1 = 28;
local2 = 42;
global = local1 + local2;
printf("Global =%d\n",global);
//Static & void function
int i;
for ( i = 0; i < 6; i++)
{
sayhello();
}
return 0;
}
/* definition */
int sq(int num){
int y;
y = num * num;
return(y);
}
int sum(int a, int b){
a += b;
return a;
}
void sayhello(){
static int num = 1;
printf("Say Hello %d \n",num);
num++;
}