Answer the following questions by creating a ten-bit binary number, abcdefghij,
ID: 3542591 • Letter: A
Question
Answer the following questions by creating a ten-bit binary number, abcdefghij, such that a digit is 1 if corresponding question is true, and 0 is it is false. Write a small C function that converts the particular binary number you found to hexadecimal. Each correct digit is worth 1 point.
a) Any C program has to return a zero when it exits if the entry point in a C program is in this
particular format : int main(int* argc, char** argv)
b) A syntax error in a C program is an error that causes the program to produce incorrect output(s),
or crash.
c) If you declare this : int single = 1, double = 2, triple = 3; in your code, it compiles fine.
d) After the last statement of any declared C function executes, such as its return statement,
control is transferred to the next defined function.
e) The symbol = is the C equality operator.
f) If you write while(0){} in your program, leaving the brackets empty, your program will stop at
that point and never exit the loop.
g) If integer z is 6, after this C statement executed z will not be incremented : if(z=5) z++;
h) A type double variable represents same range of values than can be represented by a type int
variable.
i) Given this prototype of a C function, void one(int x, double y); and assuming that the <math.h>
library header file were #included, and PI is #defined as 3.14, this following call would cause an
error : printf(
Explanation / Answer
Answer the following questions by creating a ten-bit binary number, abcdefghij, such that a digit is 1
if corresponding question is true, and 0 is it is false. Write a small C function that converts the particular binary number you found
to hexadecimal. Each correct digit is worth 1 point.
string to_hexadecimal(string binary)
{
int sum =0;
for(int i=binary.length()-1; i>=0; i++)
sum = sum + (binary[i]-'0')*pow(2,i);
char* table = "0123456789ABCDEF";
string str="";
while(sum)
{
str = table[sum%16]+str;
sum = sum/16;
}
}
a) Any C program has to return a zero when it exits if the entry point in a C program is in this
particular format : int main(int* argc, char** argv)
True
b) A syntax error in a C program is an error that causes the program to produce incorrect output(s),
or crash.
False;
c) If you declare this :
int single = 1, double = 2, triple = 3; in your code, it compiles fine.
False double is data type not a variable.
d) After the last statement of any declared C function executes, such as its return statement,
control is transferred to the next defined function.
False.. control transferred back to function where it is called.
e) The symbol = is the C equality operator.
False == is equality operator.
f) If you write while(0){} in your program, leaving the brackets empty, your program will stop at
that point and never exit the loop.
False... that code never executes
g) If integer z is 6, after this C statement executed z will not be incremented : if(z=5) z++;
False. since z=5 is not equality statement.. z will be incremented.
h) A type double variable represents same range of values than can be represented by a type int
variable.
True.
i) Given this prototype of a C function, void one(int x, double y); and assuming that the <math.h>
library header file were #included, and PI is #defined as 3.14, this following call would cause an
error : printf(
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.