![]() |
.. (לתיקייה המכילה) | |
can we use functions defined in math.h? | |
No |
Can I use stdbool.h for the HW? | |
Yes, you can use stdbool.h in this HW. |
Should we use “define” whenever we use a number? | |
Although, there is no right or wrong answer, officially it is YES. Except for 0,1 - we see a nice style approach in giving the exact meaning to the numbers you use. |
Should I return < value other than 0 > when the program gets illegal input? | |
Although you are correct, and most of the time we will return a value that’s not 0 when we have an error in the program for HW1 it does not matter. Meaning you can return 0 when exiting the program after illegal input. |
VS does not compile my program, because of safety issues with scanf. What should I do? | |
For those using visual studio, in order to remove warnings regarding scanf please add – #define _CRT_SECURE_NO_WARNINGS Just make sure to run your program on the self test website before submitting. |
I have submitted the homework, but… < for some reason I have worries >. What should I do? | |
There is no limit on the number of submissions. Solve the issue and submit again, the last update is the one being tested. Please check the deadline for the HW. |
I write -std=c99, but it disappears and i'm unable to compile my project in CodeBlocks | |
You accidentally pressed on "do not enable this known feature" and now CodeBlocks ignores your attempts go to Settings->Environment->Disabled Dialogs->Enable compiler flags?No check to re-enable the dialog you can just check this option in Settings->Compiler->Global compiler settings->General->Have gcc follow the 1999 ISO ... |
Can I use ‘For’ and ‘do-while’ loops? | |
Although we have not learned about it and will only on tutorial 4, it is okay to use these kind of loops. If you don’t know what it is, please do not feel discouraged as the exercise is solvable using ‘while’ as well. |
For Q1 – is it okay to assume that all the numbers are numbers and do not contain any other characters. | |
It is not okay to assume the input is valid, i.e. you need to check that you’re only getting a number. |
For Q1 – Are Enter/Space/Tab considered illegal characters? | |
No, You can assume that if an illegal input is given it will be a letter (a-z in capital or lowercase). As you can see in the examples given “5 10 15 -1” is a valid input whereas “a 10 15 -1” is not. |
For Q1 – Is there a limit on the maximal weight for the input? | |
Yes, you can assume that any number given will be at most 10,000 (for each ingredient). You still need to check the validity of the input. |
For Q1 – Can we assume the numbers given are all different or is the case 7 7 7 7 -3 okay? | |
You can’t assume the numbers a different, this case is okay. The meaning in the exercise of different ingredients is that every number represents a different ingredient and not that every number has to be different from the others. |
For Q1, can we assume that when a negative number is given it will be at the end of the input? | |
Yes. |
For Q1 – In the case where we get eleven numbers and then get an illegal input what should we do? | |
First of all lets see an example to make things clear. We get “ 1 2 3 4 5 6 7 8 9 10 11 # -1 ”, question is what should we do? In this case we should exit the program since we got an illegal input. We print “Too many ingredients.” only if we got a valid input and the number of ingredients is bigger than 10. |
For Q1- Is the case where the user enter the following “1 3 2..1 -1” legal? | |
First of all let’s see what is the problem, here the user enters 2..1 instead of 2.1, this results in scanf getting two numbers 2.0 and 0.1. You can assume this case will not happen. |
For Q1 – What should we do in case we get “-1a” (and a like)? | |
This case will not happen. Meaning the user enters the input with spacing however some of the entries might be letters and then you should proceed as per the HW instructions. |
For Q2 - is it okay to assume that only one character was inserted when asked for a letter to find? | |
Yes you can assume only one character is inserted when asking for the letter to find. |
For Q2 – can we assume something about the number of appearances of the letter to count? | |
Yes, you can assume that the number of appearances for the letter to count can be represented by the type int. |
For Q2 – For the series of characters, can I assume the symbol # will appear only at the end? | |
Yes, you can assume the symbol # will appear only at the end and it is guaranteed to be the last character. |
For Q2 – When the user is asked to give a letter to count if we get a space (32 on the ascii table) should we stop? | |
Yes space is considered an illegal input, therefore you should stop when receiving space as the letter to count. |