Sample Code Set - 01

Written on December 03, 2025

4 min. read

1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>

int update(int a) 
{
    a = a * 2;
    return a;
}

int main() 
{
    int a = 5;
    printf("%d ", update(a));
    a = update(a);
    printf("%d", a);
    return 0;
}

2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>

int main() 
{
    int a = 10;
    printf("%d\n", a);
    {
        int a = 25;
        printf("%d\n", a);
    }
    printf("%d\n", a);
    return 0;
}

3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>

int x = 5;

void test() 
{
    int x = 20;
    printf("%d\n", x);
}

void demo() 
{
    printf("%d\n", x);
}

int main() 
{
    printf("%d\n", x);
    test();
    demo();
    printf("%d\n", x);
    return 0;
}

4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>

int main()
{
    int a = 10;
    int b = a + 5;
    printf("%d %d\n", a, b);
    {
        int a = b + 10;
        int b = a * 2;

        a = a + 3;
        b = b - 5;

        printf("%d %d\n", a, b);
    }
    a = a * 2;
    b = b + 20;
    printf("%d %d\n", a, b);
    return 0;
}

5

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
#include <stdio.h>

int x = 5;
int y = 3;

void test()
{
    int x = 20;
    y = y + 2;
    x = x + y;
    y = y * 2;
    printf("%d %d\n", x, y);
}

void demo()
{
    int y = 50;
    x = x + 1;
    printf("%d %d\n", x, y);
}

int main()
{
    printf("%d %d\n", x, y);
    x = x * 3;
    y = y + 5;
    test();
    demo();
    printf("%d %d\n", x, y);
    return 0;
}