/* * I'm a comment. */ #include // To perform input / output, printf and scanf #include // To add EXIT_SUCCESS and EXIT_FAILURE, cf end of the main method. long cube(long x){ return x * x * x; } int main(){ int a; a = 10; int b = 11; printf("The value of a is %d, its address is %p\n", a, &a); //%d is for sigmed integers, %p for pointer address int* pointer = &a; // You can also see the syntax "int *pointer = &a;". printf("The value pointed is %d, the address of the pointer is %p, the address the pointer points to is %p.\n", *pointer, &pointer, pointer); // Notice that if the value of change a, so does the value pointed at. We can read the new value from the user: printf("Enter the new value for a and press enter:\n"); scanf("%d", &a); printf("The value pointed is %d\n", *pointer); // Basic control stucture: if (a == 10){ printf("You did not changed the value of a.\n"); } else { printf("You changed the value of a.\n"); } int counter; printf("Let's count to ten:\n"); for (counter = 0; counter <= 10 ; counter++) { printf("%d ", counter); } printf("\n"); printf("Let's count back to 0:\n"); while (counter > 0) { counter--; printf("%d ", counter); } printf("\n"); // Calling the previously defined cube function, performing implicit casting from int to long: printf("Here is your number, cubed: %d\n", cube(a)); /* To exit informing the environment that our program completed successfully, we can use: * return(0); * exit(0); * or, more portable: */ exit(EXIT_SUCCESS); }