/*
This is the fourth lab of Lab EE107
The purpose of this lab is to understand the difference between pre-increment and post increment
The purpose is to create the code and free of syntax and grammatical errors
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: Feb 6, 2024.
    */
#include <stdio.h>

int main() {
    // Declaring integer variables for post-increment
    int integer_EU = 2;
    int result_EU;
    
    // Post-increment: The current value of 'integer_EU' is used in the expression, then incremented
    result_EU = 2 * (integer_EU++);
    
    // Printing the result and the updated value of 'integer_EU'
    printf("result_EU = %d\n", result_EU);
    printf("%d\n", integer_EU);

    // Declaring integer variables for pre-increment
    int integer_EU_2 = 4;
    int result_EU_2;
    
    // Pre-increment: 'integer_EU_2' is incremented first, then its updated value is used in the expression
    result_EU_2 = 4 * (++integer_EU_2);
    
    // Printing the result and the updated value of 'integer_EU_2'
    printf("result_EU_2 = %d\n", result_EU_2);
    printf("%d\n", integer_EU_2);

    return 0;
}

Embed on website

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