#include <stdio.h>
int main()
{
int a = 126; //定义整型变量a并赋值
long b = -123457; //定义长整型变量b并赋值
unsigned c = 50000; //定义无符号变量c并赋值
printf("%d,%o,%x\n", a, a, a); //分别按十进制、八进制及十六进制输出
printf("%5d,%-5d\n", a, a); //分别按右对齐、左对齐格式输出
printf("%10ld,%3u,%x\n", b, c); //指定宽度输出
system("pause");
return 0;
}
实验3.2
#include <stdio.h>
int main()
{
int a;
float b;
printf("Enter a and b: "); //输出提示
//scanf("%d%f",&a,&b); //输入a、b的值
scanf("%3d%5f", &a, &b);
printf("\na=%d,b=%f\n", a, b); //输出a、b的值
system("pause");
return 0;
}
实验3.3
#include <stdio.h>
int main()
{
int a, b;
a = sizeof(3 + 5.0); // 浮点数的字节长度
b = sizeof 3 + 5.0; // int整型数据字节长度4 + 5=9
printf("%