User Tools

Site Tools


qna:lab-session:code8

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

qna:lab-session:code8 [2024/04/25 11:22] (current)
xallos created
Line 1: Line 1:
 +<code c>#include <stdio.h>
  
 +int howManyTimes() {
 +    static int counter = 0;
 +
 +    return ++counter;
 +}
 +
 +int main() {
 +    printf("Function has been called %d times\n", howManyTimes());
 +    printf("Function has been called %d times\n", howManyTimes());
 +    printf("Function has been called %d times\n", howManyTimes());
 +    printf("Function has been called %d times\n", howManyTimes());
 +    printf("Function has been called %d times\n", howManyTimes());
 +
 +    return 0;
 +}</code>
qna/lab-session/code8.txt ยท Last modified: 2024/04/25 11:22 by xallos