C Tutorial/Data Type/int Display
Версия от 14:21, 25 мая 2010;  (обсуждение)
Displaying Integer Data Types with printf: %d
#include <stdio.h>
main(){
    int operand1;
    operand1 = 29;
    printf("The value of operand1 is %d", operand1);
}The value of operand1 is 29
Printing integers right-justified
#include <stdio.h>
int main()
{ 
   printf( "%4d\n", 1 );
   printf( "%4d\n", 12 );
   printf( "%4d\n", 123 );
   printf( "%4d\n", 1234 );
   printf( "%4d\n\n", 12345 ); 
   printf( "%4d\n", -1 );
   printf( "%4d\n", -12 );
   printf( "%4d\n", -123 );
   printf( "%4d\n", -1234 );
   printf( "%4d\n", -12345 );
   return 0;
}1 12 123 1234 12345 -1 -12 -123 -1234 -12345
