In the final code snippet, powers of 2 and 9 are printed, as follows:
printf( "Powers of 2: 2^0, 2^2, 2^4, 2^6, 2^8 , 2^10\n" );
int k = 1;
for( int i = 0 ; i < 6 ; i++ , k<<=2 ) {
printf( " [%6d] [%-6d] [%-.6d] [%6.3d] [%-6.3d] [%d]\n" ,
k , k , k , k , k , k );
}
printf( "\nPowers of 9: 9^1, 9^2, 9^3, 9^4\n" );
k = 9;
for( int i = 0 ; i < 5 ; i++ , k*=9 ) {
printf( " [%6d] [%-6d] [%-.6d] [%6.3d] [%-6.3d] [%d]\n" ,
k , k , k , k , k , k );
}
In these printed values, we will pay particular attention to the formatted output—how they are aligned, whether they are zero-filled, and how the precision specifier changes them, if at all.
Enter these code snippets into signedInt.c. Compile and run the program. You should see something similar to the following output:
Pay particular attention to the differences...