SPI SEPT 2020
TUTORIAL
WEEK 5
15TH OCT 2020
Things to submit:
UNIT 5: UNIT 6:
1. Activity 5.1 1. Activity 6.3
2. Activity 5.2 2. Exercise 6.2
3. Activity 5.4 3. Exercise 6.3
4. Activity 5.7
5. Exercise 5A
Link Submission:
[Link]
nWBFUBCpDgJL47RN5-
_9vWCSFIVQf5QIwuQie4WW6YZZ2l1wy5-
qMnzzAITABb5TwnhXtMbbA/pubhtml?
gid=1034784007&single=true
QUESTION & ANSWER
Extra info:
#include<stdio.h>
int main(void)
{
char entry;
printf(“\nPlease enter a letter ”);
scanf(“%c”,&entry);
switch(entry){
case ‘a’…’z’:
case ‘A’…’Z’:
printf(“This is a letter %c \n”, entry);
break;
default:
printf(“%c is not a letter \n”, entry);
break;
}
return 0;
}
Exercise 6.2:
Get min
1. Ask user input for min, max, and div do
2. min < div < max
Get max
3. 1 < div < 11
max <= min while
max
do
1. div <= min Get div
2. div >= max
while
3. div <=1 or div >=11 div
Remainder operator: List number between min and
% max that can be divided by div
Exercise 6.3:
1. Keep asking for user input n until user do
entered n < 1 or n > 100
Get n
2. Calculate total of all valid numbers n>0
3. Calculate average n < 101 while
n
n < 1 , n > 100
Print
1. total for all valid numbers
2. Average = sum/count