Question #1: first question Hi. I am working on a systems assignment and I am gi
ID: 3548997 • Letter: Q
Question
Question #1: first question
Hi. I am working on a systems assignment and I am given the problem on finding the factorial of an abritrary number using the do while loop. I am having trouble implementing the code. The error that it is giving me is "expected while before return". What is this implying? Here is my Code:
int res = 1;
int i = 2;
do{
res *=1;
i++;
}
return res;
while (i<n);
}
Question #2: I also have another question:
Implement function ranges that takes no input and prints the ranges (i.e., the minimum and maximum legal values) of integer types char, short, int, long, and long long, both signed and unsigned. You should do this by printing appropriate constants defined in header file <limit.h> located in directory /usr/include. Your output should be similar to:
signed char
minimum value: -128
maximum value: 127
unsigned char
minimum value: 0
maximum value: 255
signed short
minimum value: -32768
maximum value: 32767
... (and so on)
My question on this one is....What does it mean for something to be signed or unsigned? Could you perhaps give me an example?
Thank you very much
Explanation / Answer
1)
int res = 1;
int i = 2;
do{
res *=1;
i++;
}
while (i<n){
return res;
}
2)
signed allows for negative values and unsigned does not. Therefore unsigned can have more (positive) values then unsigned.
If you to enter negative values also then choose signed or else choose unsigned.
Have a nice day :)