/* This is the twelveth lab of Lab EE107
The purpose of this lab for illustrate static and automatic variables.

Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: April 16th, 2024.
*/
#include <stdio.h>

// Function prototype for auto_static_EU function
void auto_static_EU(void);

int main(void) {
    int i;

    // Loop to call auto_static_EU function 5 times
    for (i = 0; i < 5; ++i) {
        auto_static_EU();
    }

    return 0;
}

// Definition of auto_static_EU function
void auto_static_EU(void) {
    // Declaration and initialization of automatic variable autoVar_EU
    int autoVar_EU = 1;
    
    // Declaration and initialization of static variable staticVar_EU
    static int staticVar_EU = 1;

    // Print values of automatic and static variables
    printf("automatic = %d, static = %d\n", autoVar_EU, staticVar_EU);

    // Increment automatic and static variables
    ++autoVar_EU;
    ++staticVar_EU;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: