[ create a new paste ] login | about

Link: http://codepad.org/Yahy4TBw    [ raw code | output | fork ]

C, pasted on Jul 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main(void) {
    //---------------- 1 ------------------
    int pos = 1;
    int count = 3;
    int i;
    for(i = 0; i < count; i++) // caluculate 2^n
        pos *= 2;
    printf("Code1: pos = %d\n", pos); 

    //---------------- 2 ------------------
    pos = 1;
    count = 3;
    pos = pos << count;
    printf("Code2: pos = %d\n", pos); 

    return 0;
}


Output:
1
2
Code1: pos = 8
Code2: pos = 8


Create a new paste based on this one


Comments: