Tất cả câu hỏi
Ngân hàng câu hỏi trắc nghiệm có giải thích chi tiết.
#include <stdio.h>
void main()
{
int total=0;
for(int s=1; s<15; s++)
total=total+s;
printf("%d",total);
}int 2_var = 15;
printf("%d", 2_var);#include <stdio.h>
int main()
{
int x = 5, y = 3, z = 1;
x = x % 3 + z++;
z = x * y--;
printf("%d %d %d", x, y, z);
return 0;
}char s[] = "AbCd";
printf("%d;%d;%d;%d", s[1], s[2], s[3], s[4]);#include <stdio.h>
int main() {
int arr[] = {5, 10, 15};
for (int i = 0; i < 3; i++)
printf("%d ", arr[i]);
return 0;
}#include <stdio.h>
int main() {
int quantity;
double cost;
printf("Enter the number of apples desired: ");
scanf("%d", &quantity);
printf("Now enter the cost of one apple (in $): ");
scanf("%lf", &cost);
printf("That will cost $%.2lf\n", quantity * cost);
return 0;
}Đáp án đúng: "Throughout the entire program". Biến khai báo ngoài mọi hàm có phạm vi tệp và thời gian sống tĩnh: nó được cấp chỗ một lần khi chương trình nạp và tồn tại tới lúc kết thúc, nên mọi hàm viết sau khai báo đều thấy nó, và tệp nguồn khác cũng dùng được qua khai báo extern; đó chính là nghĩa của cả chương trình. Mô tả "Only within the function where it's declared" ứng với biến cục bộ, thứ sinh ra trên khung ngăn xếp mỗi lần gọi hàm rồi mất đi khi hàm trả về. Mô tả "Only within the block where it's declared" là phạm vi khối, áp cho biến khai báo trong cặp ngoặc nhọn của thân vòng lặp hay nhánh rẽ. Mô tả "Within the structure where it's defined" nhầm biến với trường của struct; trường chỉ là thành phần của một kiểu, chạm tới qua tên biến struct chứ không phải một biến toàn cục.
char str1[] = "Hello";
char str2[10];
strcpy(str2, str1);void main()
{
int const *p = 5;
printf("%d", ++(*p));
getchar();
}int a[5] = {1, 2, 3};
printf("%d", a[4]);pointersvaluetypeaddressint a[MAX_SIZE];
int s = 0;
for (int i = 0; i < n; i++)
s = s + a[i] * a[i];#include <stdio.h>
double average(int a, int b, int c) {
double result;
result = (a+b+c)/3.0;
return result;
}
int main() {
printf("%.6f", average(5, 8, 7));
return 0;
}