第九题 #include <stdio.h> int main() { float f=0.0f; int i; ;i<;i++) f = f + 0.1f; if(f == 1.0f) printf("f is 1.0 \n"); else printf("f is NOT 1.0\n"); ; } 知识点讲解: 浮点寄存器 浮点寄存器是FPU的组成部分.硬件架构不同,浮点寄存器的个数和位数也不同.X86架构的浮点寄存器有: 1)8个80位的数据…
第五十一题 Write a C function which does the addition of two integers without using the '+' operator. You can use only the bitwise operators.(Remember the good old method of implementing the full-adder circuit using the or, and, xor gates....) 题目讲解: 参考:ht…
第四十六题 What does the following macro do? #define ROUNDUP(x,n) ((x+n-1)&(~(n-1))) 题目讲解: 参考:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=814501 用于内存对齐,n为2的幂. 第四十七题 Most of the C programming books, give the following example for the definitio…
第三十八题 What is the bug in the following program? #include <stdlib.h> #include <stdio.h> #define SIZE 15 int main() { int *a, i; a = malloc(SIZE*sizeof(int)); ; i<SIZE; i++) *(a + i) = i * i; ; i<SIZE; i++) printf("%d\n", *a++);…
第三十四题 The following times. But you can notice that, it doesn't work. #include <stdio.h> int main() { int i; ; ; i < n; i-- ) printf("-"); ; } Well fixing the above code is straight-forward. To make the problem interesting, you have to f…
第三十一题 The following is a simple C program to read and print an integer. But it is not working properly. What is(are) the mistake(s)? #include <stdio.h> int main() { int n; printf("Enter a number:\n"); scanf("%d\n",n); printf(&quo…
第二十六题(不会) The following is a simple program which implements a minimal version of banner command available on most *nix systems. Find out the logic used in the program. #include<stdio.h> #include<ctype.h> char t[]={ ,,,,,,,,,, ,,,,,,,,,, ,,,,,…
第二十一题 What is the potential problem with the following C program? #include <stdio.h> int main() { ]; printf("Enter the string:"); scanf("%s",str); printf("You entered:%s\n",str); ; } 题目讲解: 易造成数组越界,scanf改成如下形式比较保险 scanf(…