babyip wrote:

hello, i have a problem using printf() function, would u please help me?

i have a program to print numbers on screen, each number occupies five

spaces and the range of the number is from -9 to 9.

my question is, how can i place the number in the middle of the five spaces?

thanks!

here is my example (allow me to use underline "_" to represent space " ")

"__1__" <==positive number at the third position

"__-4_" <==the negative symbol at the third position, and the number at

the fourth position

#include <stdio.h>

int main(void) {

int i;

for (i = -9; i < 10; ++i)

printf(" %d%s\n", i, i < 0 ? " " : " ");

return 0;

}

--

Joe Wright

"Everything should be made as simple as possible, but not simpler."

--- Albert Einstein ---