Solution for Exercise 6-1
ex0601
#include <stdio.h> int main() { int x; x = 5; printf("The value of variable x is %d.\n",x); return(0); }
Notes
* I generally place a blank line — white space — after variable declarations in my code.
* The order is important when you assign a value to a variable. The value, or equation or function, always goes on the right. The variable always goes on the left. It never looks like this:
The above statement doesn't work in the C language.
* The x in printf()'s formatting string is simply the letter x. That's because it appears in the double quotes, and it's not an escape sequence or a placeholder.
* I suppose x is a common variable name thanks to algebra. "What is the value of x?" X is unknown. It's also one of the coolest letters of the alphabet, right up there with Z. If you're a bad guy or an evil alien, your name probably starts with an X or a Z. Of course, z isn't a common variable name, which is odd.
Copyright © 1997-2024 by QPBC.
All rights reserved