Summer 2017 PROG 20 ro7 Midterm Sheridan College Institute of Technology and Adv
ID: 3850421 • Letter: S
Question
Summer 2017 PROG 20 ro7 Midterm Sheridan College Institute of Technology and Advanced Learning Faculty of Applied Science and Technology Midterm Date: 201706/19 Student Name Student Number 1. We want to get two integer numbers from user as Input1 and Input2. The maximum value for these integers are 220 and 150, respectively Next, we will multiply these two integers and save the result in another variable, Result. What data types should we use for unput1, Input2 and Result to use memory efficiently? (3pt) 2. Which of the following is valid identifier in c? circle the valid ones and write the reason for invalid identifiers. (5pt) a. Number 1 b. Number(1) c. Number 1 d. Number1 e, 1 Number Answer: How would you test whether xis the ascii code for a lower case letter without using any library function and without mentioning any number and only one line of code? (3pt) nswer:Explanation / Answer
1. For the variables Input1,Input2 and Result we can use the data type
short int, which requires 2 bytes in memory for storing the
integer values. The range of short int is –32,767 to 32,767
2. valid indentifiers are
a. Number1
c. Number_1
d. _Number1
Invalid identifiers are
b.Number(1)
e.1Number
Reason : No special characters are allowed except underscore(_).
variable cannot start with a number.
3. int main()
{
int x,f;
x=12;
f= ( x >= 'a' && x <= 'z')? 1 :0;
printf("%d",f);
return 0;
}
if the value of f is 1, then it is the ascii value of a lowercase letter, otherwise not.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.