#include <stdio.h>
int seq(void){
static int v = 5, d = 1;
int ret = v;
v += d;
if(v == 5 || v == 7) d = -d;
return ret;
}
int main(void) {
for(int i = 0; i < 20; ++i)
printf("%d ", seq());
return 0;
}
More Related Contents:
- HOW to back for the beginning if the user press any key except 1 or 2 or 3? [closed]
- I need help understanding this code in C [closed]
- Simple counters not working in C
- break statement doesn’t work in a loop [closed]
- Finding target sum of two numbers in array
- How to break out of while loop in C
- do { … } while (0) — what is it good for? [duplicate]
- C loop optimization help for final assignment (with compiler optimization disabled)
- Validate the type of input in a do-while loop C
- For vs. while in C programming?
- Effect of semicolon after ‘for’ loop
- Is it faster to count down than it is to count up?
- No loop condition in for and while loop
- How to optimize these loops (with compiler optimization disabled)?
- Validate the type of input in a do-while loop
- When implementing an infinite loop, is there a difference in using while(1) vs for(;;) vs goto (in C)?
- Is there any way to loop through a struct with elements of different types in C?
- How can I optimize these loops (with compiler optimization disabled)?
- How can I break out of two nested for loops in Objective-C?
- Anonymous Struct Pointer [closed]
- Pthreads in C. Simple example doesn’t work [closed]
- Convert a character digit to the corresponding integer in C
- Calculating factorial of large numbers in C
- MPI_Bcast a dynamic 2d array
- What are .a and .so files?
- Why do strings in C need to be null terminated?
- Count each bit-position separately over many 64-bit bitmasks, with AVX but not AVX2
- Android read text file from asset folder using C (ndk)
- Returning a struct pointer
- Swift: How to call a C function loaded from a dylib