C - Write program to define int type variable

Requirements

Declare an integer variable my_int and assign it the value 22.

Have a printf() statement display the variable's value.

Have a second printf() statement display that value plus 16.

Then have a third printf() statement that displays the value of my_int multiplied by itself.

Demo

#include <stdio.h>

int main()//from w ww  .j av a 2 s. c  om
{
    int my_int;

    my_int = 22;

    printf("The value of my_int is %d.\n",my_int);
    printf("The value of my_int plus 16 is %d.\n",my_int+16);
    printf("The value of my_int times itself is %d.\n",my_int*my_int);
    return(0);
}

Result

Related Exercise