Given the following definition statement:
char a[] = "Digipen";evaluate expression strlen(a) where function strlen is declared in C standard library header <string.h>. If the expression cannot be compiled, write [for compile-time error]. If the expression generates undefined behavior, write [for undefined behavior]. Otherwise, write the exact value resulting from the expression's evaluation.
Brief side-note on undefined behavior: The C standard says that statements such as c = (b = a + 2) - (a = 1); and c = (b = a + 2) - (a = 1); cause undefined behavior [because we don't know whether the left or right operand of operator - is evaluated first]. When a program ventures into the realm of undefined behavior, all bets are off. The program may behave differently when compiled with different compilers. But that's not the only thing that can happen. The program may not compile in the first place, if it compiles it may not run, and if it does run, it may crash, behave erratically, or produce meaningless results. In other words, undefined behavior should be avoided like the plague.
Given the following definition statement:
char const *d = "Digipen";evaluate expression sizeof(d). If the expression cannot be compiled, write [for compile-time error]. If the expression generates undefined behavior, write [for undefined behavior]. Otherwise, write the exact value resulting from the expression's evaluation.
Brief side-note on undefined behavior: The C standard says that statements such as c = (b = a + 2) - (a = 1); and c = (b = a + 2) - (a = 1); cause undefined behavior [because we don't know whether the left or right operand of operator - is evaluated first]. When a program ventures into the realm of undefined behavior, all bets are off. The program may behave differently when compiled with different compilers. But that's not the only thing that can happen. The program may not compile in the first place, if it compiles it may not run, and if it does run, it may crash, behave erratically, or produce meaningless results. In other words, undefined behavior should be avoided like the plague.
Given the following definition statement:
char c[] = {'D', 'i', 'g', '\0', 'i', 'p'};evaluate expression sizeof(c). If the expression cannot be compiled, write [for compile-time error]. If the expression generates undefined behavior, write [for undefined behavior]. Otherwise, write the exact value resulting from the expression's evaluation.
Brief side-note on undefined behavior: The C standard says that statements such as c = (b = a + 2) - (a = 1); and c = (b = a + 2) - (a = 1); cause undefined behavior [because we don't know whether the left or right operand of operator - is evaluated first]. When a program ventures into the realm of undefined behavior, all bets are off. The program may behave differently when compiled with different compilers. But that's not the only thing that can happen. The program may not compile in the first place, if it compiles it may not run, and if it does run, it may crash, behave erratically, or produce meaningless results. In other words, undefined behavior should be avoided like the plague.
Given the following definition statement:
char b[] = {'D', 'i', 'g', 'i', 'p', 'e', 'n'};evaluate expression sizeof(b). If the expression cannot be compiled, write [for compile-time error]. If the expression generates undefined behavior, write [for undefined behavior]. Otherwise, write the exact value resulting from the expression's evaluation.
Brief side-note on undefined behavior: The C standard says that statements such as c = (b = a + 2) - (a = 1); and c = (b = a + 2) - (a = 1); cause undefined behavior [because we don't know whether the left or right operand of operator - is evaluated first]. When a program ventures into the realm of undefined behavior, all bets are off. The program may behave differently when compiled with different compilers. But that's not the only thing that can happen. The program may not compile in the first place, if it compiles it may not run, and if it does run, it may crash, behave erratically, or produce meaningless results. In other words, undefined behavior should be avoided like the plague.
Given the following definition statement:
char a[] = "Digipen";evaluate expression sizeof(a). If the expression cannot be compiled, write [for compile-time error]. If the expression generates undefined behavior, write [for undefined behavior]. Otherwise, write the exact value resulting from the expression's evaluation.
Brief side-note on undefined behavior: The C standard says that statements such as c = (b = a + 2) - (a = 1); and c = (b = a + 2) - (a = 1); cause undefined behavior [because we don't know whether the left or right operand of operator - is evaluated first]. When a program ventures into the realm of undefined behavior, all bets are off. The program may behave differently when compiled with different compilers. But that's not the only thing that can happen. The program may not compile in the first place, if it compiles it may not run, and if it does run, it may crash, behave erratically, or produce meaningless results. In other words, undefined behavior should be avoided like the plague.
It is a compiler error to subtract two pointers that are referencing different arrays.
It is a compiler error to use pointer arithmetic with a pointer that does not reference an array.
Adding to a pointer increases the address stored in the pointer by byte.
Given the definitions
int array[1000];
int *pa;
is the expression pa = array valid?
The partial pressure of O2 in the atmosphere at sea level is 21.3 kPa. What is the partial pressure of O2 on the top of a mountain, where the atmospheric pressure is 65.1 kPa?Assume the mole fraction of O2 remains constant.
[Atmospheric pressure at sea level is 101.3 kPa.]