C Programming for Engineers Fall 2007-8
Practical Sessions Page
|
Teaching Assistant: |
|
|
Class: |
Thursday 9:10 - 11:00 or 13:10 - 15:00 |
|
Email: |
|
|
Office phone: |
6409759 |
|
Office hour: |
Tuesday 15:10-16:10, Shenkar-Physics 406 (or set time via email/phone) |
|
Mailbox: |
252 (Schreiber, 1st floor, near the elevator) |
Lecturer: Amitai Armon, Email: armon@post.tau.ac.il, Course's url: C for Engineers
Reinforcement Sessions url: Reinforcement Sessions
Announcements
|
Date |
Message |
|
|
Welcome to the course! |
|
21/10/07 |
Homework submission guidelines can be found here |
|
21/10/07 |
Instructions on how to print your program’s output can be found here |
|
21/10/07 |
Instructions on how to download and use the free "Visual Studio Express" can be found here |
|
25/10/07 |
To better fit your weekly schedule, my office hour has changed to Tuesday 15:10-16:10 |
|
25/10/07 |
Printing: you can print your exercises from any computer in the exercise classes located around the building (rooms 008, 009, 010...). You can collect the printout from any printer in the area (each room should contain at least one) by using your credit card for the specific printer. In case of trouble, consult the support team around |
|
25/10/07 |
You can directly download the "Visual Studio Express" edition here Instructions on how to use the Visual Studio Express edition can be found here |
|
1/11/07 |
Homework #2 has slightly changed, if you downloaded if before today, please take the new version! |
|
6/11/07 |
My office hour for today is canceled please write me an email if you need assistance |
|
12/11/07 |
Reinforcement sessions in C for all engineering students are going to be held by me on Thursdays 18:10-20:00. The first meeting is scheduled for Novermber 22th. The purpose of these meetings is to enhance the material taught in class (lectures and practical sessions). During every session we shall focus on the subject taught on that week. The sessions will include (1) Guided solution to a given problem/s (2) Self work (with my help) on additional problem/s (3) Answers to personal questions/difficulties. You are all invited to come! The sessions url can be found here |
|
13/11/07 |
This is a
simple tutorial for using the C Debugger |
|
18/11/07 |
Since I was asked to replace another teaching assistant (his classes are "on" my office hour), I am moving my office hour for this week to Tuesday 20.11 at 11-12 at my office |
|
19/11/07 |
For students who are having problems with the visual studio express, here is an alternative: working with the LCC compiler |
|
22/11/07 |
IMPORTANT - SOFTWARE REGISTRATION Make sure to REGISTER your copy of Microsoft Visual C++ Express edition. Registration is free, but if you don't do it - your license will expire after a month. |
|
27/11/07 |
A list of the C math library functions can be found here. |
|
27/11/07 |
Please do not send me complete programs and say they do not compile/work. I will respond only to focused questions, after I will be convinced you debugged the program, found the problematic location in it and still can not understand what is wrong. To such questions please attach the compilation/running errors and be as specific and accurate as you can, you can attach a screen shot, if you want. |
|
27/11/07 |
This Thursday I have to finish early the 13-15 class. Thus, we shall start at 13:05 and finish at 14:45 without a break. Please try to be on time! |
|
29/11/07 |
Ben (Another TA in this course) will replace me today in the 13-15 class. Class will be as usual (starting at 13:10 with a break) - sorry for the balagan. |
|
2/12/07 |
A 20 points bonus is given for question #2 in this week's homework. Check Q&A for details |
|
10/12/07 |
There is a small mistake in my explanations of question #1. It is written "for an array A, A[i][j] will be multiplied (and summed) with every A[x][y], x > i, y > j". This is not accurate! A[i][j] will be multiplied (and summed) with every A[x][y], whereas x > i OR (x == i AND y > j). For example A[2][2] will be multiplied with A[2][3], A[2][4], A[3][0],....,A[4][4]. |
|
10/12/07 |
My office hour this week is moved to Monday 14-15 |
|
13/12/07 |
I am in miluim next week. My classes are going to be held as usual, but my office hour is canceled and I will not be able to respond quickly to your emails. Please contact Amitai with questions related to your homework. |
|
23/12/07 |
Everyones' grade to homework #7 is going to increase by 3 points (the "while(1)" deduction is cancelled). The updated grades file is going to be published toward the end of this week |
|
27/12/07 |
A minor change in homework 10, if you downloaded it early today, please download again the revised verion. The 5 points bonus was discarded since you did not learn the answer to it yet (you will learn it Wednesday in the lecture). |
|
1/1/08 |
A list of some selected functions from the library string.h can be found here. |
|
9/1/08 |
Amitai asked me to announce (also) here: Shiur-Hashlama will take place this Sunday, 13/1, at 15:00-17:00, in the Rosenblat Auditorium, Handasat-Tochna building (it's instead of the week in which the gates were closed). |
|
10/1/08 |
The submission on homework #12 (published today) is postponed to Sunday 20.1. Homework #13 will not be obligatory, and its deadline will be toward the exam. Make sure to solve it since "Linked-Lists" is an important topic in this course! |
|
10/1/08 |
I will conduct a Q&A session before the exam. The exact time and place will be published when it is decided. Please send me questions you'd like me to solve in advance!. |
|
10/1/08 |
Due to the 1 hour strike at 13-14, I shall start the practical session at 14:00 sharp!. |
|
13/1/08 |
This week my office hour will be held on Tuesday 16:30-17:30 (instead of 15-16). |
|
17/1/08 |
I will conduct a Q&A session on Thursday 31.1, 11-13 at Wolfson building class 238. Please try to send me questions in advance. In case I wont get questions I will solve last year's exam. |
|
17/1/08 |
Since you only have 3 days to prepare to the exam, I strongly recommend you to start learning before your first exam (which as I understood is a week from now), or at least start working on the last homework assignment. GOOD LUCK!
|
|
17/1/08 |
Previous exams + solutions can be found at Amitai's site's message board |
|
20/1/08 |
There is a MINOR update in the file list.c that you use for your 13th homework (question #3). It is in the comments of the function add_item (lowest <-> highest). Neadless to say, that this does not affects the execution, just the clearness of the code. |
|
31/1/08 |
Please go over the homework grades file at the site, and make sure that non of your grades is missing/wrong. Deadline for appeals and problems with the grades of assignments 1-12 will be next Tuesday 5.2. Your assignments can be found at cabins 121 (hw #11), 122 (hw #12), 123 (leftovers from hw #1-10) at Wolfson building behind the left elevator at the ground floor. |
|
31/1/08 |
'Daf ezer' that you will receive with the exam can be found here |
|
31/1/08 |
Solution to homework #13 (linked list) was published. |
|
31/1/08 |
I will not be available via email through the weekend (my computer is out of order) - sorry. Good luck on Sunday! |
|
14/2/08 |
Grades for homework #13 (bonus) are available |
|
17/2/08 |
The (graded) homework #13 can be found at cabin 125 at Wolfson building behind the left elevator at the ground floor. |
Practical Sessions
|
Week |
Class |
Code |
Handouts |
Slides |
Homework |
Solutions |
|
|
Introduction, first c program, variables |
|||||
|
1/11/07 |
Variables, Arithmetic Operations, Casting |
|
||||
|
8/11/07 |
Flow control: if-else, logical operators, switch |
|
||||
|
15/11/07 |
Loops |
|
||||
|
22/11/07 |
Functions |
|
||||
|
29/11/07 |
Arrays |
|
||||
|
6/12/07 |
More on Arrays |
|
||||
|
13/12/07 |
Strings |
|
||||
|
19/12/07 |
Pointers |
|
||||
|
27/12/07 |
More on Pointers |
|||||
|
3/1/08 |
Recursion |
|
||||
|
10/1/08 |
Structures, Dynamic Memory Allocation |
|
||||
|
17/1/08 |
Linked Lists |
|
Q&A
|
Date |
Question |
Answer |
|
1/11/07 |
clarifications on implicit cast |
Here are a few clarifying examples with explanations, try to compile and run it at home: int a = 4.5; // implicit cast from double (4.5) to int (4), it is legal but might cause problem, thus usually results with a compilation warning (possible lose of data) double x = 4; // implicit cast from int to double, no compilation warning since "int is a double" relation hold printf("%g\n", a); // printf/scanf is "dumb", in this case there is no compilation warnings, but the output will be wrong printf("%d \n", 2.5); // same here: no warnings, wrong output |
|
4/11/07 |
How come the course does not have a site at the virtual TAU? |
CS (Computer Science) courses use the CS website and not virtual TAU (which was created for people who can't maintain their own website) |
|
4/11/07 |
Every time I use scanf I get a compiler warning, what should I do? |
If you get the warning "warning C4996: 'scanf' was declared deprecated", just ignore it (but make sure that you do not have other warnings, and that your code works as requested, of course) |
|
15/11/07 |
Are we allowed to bring help-material (such as our notebook) to the final exam? |
No |
|
18/11/07 |
A few questions related to homework #4: 1. When am I supposed to check whether the user's input is legal 2. What is the input for question #2? Is it a number? Letters? 3. can you explain the input for question #1? |
1. You are to assume that the input is legal as long as you are not told otherwise. 2. The input is a number (representing the triangle's side's length) the output is the letters' triangle. 3. You are supposed to get input from the user as long as you are given non-negative numbers. When the first negative number is given you are supposed to stop and calulate the required statistics (only on the non-negative numbers). For example here is a legal output of the program: please enter a number: 4 please enter a number: 6 please enter a number: -3 max: 6 min: 4 total: 10 average: 5 |
|
19/11/07 |
A question related to homework #4, question #3: When we get the first number that is smaller then epsilon, are we supposed to add it to the sum, or not? |
You are supposed to add the first number that is smaller then epsilon, as defined in the question. |
|
19/11/07 |
I am having little mistakes in my code that makes the program work differently then I planned. Do you have suggestions on how to find my mistakes? |
There are a few ways to debug your program. The first, and simplest it to use 'printf'. For example, if you are not sure that your loop executes its body enough times, you can put a 'printf' in it like here: for (i = 0; i < 10; ++i) { printf("iteration # %d", i); execute loops' body here } Another option would be to use the debugger. You can learn how to use it by yourself, or wait till we do it in tirgul... |
|
20/11/07 |
In homework #4, question #1: what am I supposed to do if the first input from the user is negative? |
If the first number the user enters is negative, then there is no meaning for the max, min, sum and average. Thus, in such a case you are supposed to print an appropriate message and to exit the program (return 0). |
|
27/11/07 |
A few questions related to homework #5: 1. In question #1, do we have to write a program that recieves an input from the user or use the input given in the exercise 2. In question #3, do we have to ask the user to choose an option each time (1-area, 2-perimeter, 3-isosceles), or should the program terminate after one choice? 3. I am getting a warning when using abs in question #1 |
1. You are supposed to use the inputs given there. 2. You are requested to keep ask the user until he terminates. Recall that the user terminates the program by giving a choice not in the legal range (1-3) 3. The signature of abs in C is int abs (int x), so it is not the correct function to use in question #1 (as it will refer to the input as int, while it is double)! The correct function to use would be fabs (signature: double fabs (double x)). Check here. |
|
27/11/07 |
In homework #5, question 3, can we assume that the 3 points are not on the same line? |
Yes |
|
2/12/07 |
In homework #6, question 2, I found a solution without using an array, is it ok? |
Yes, you are allowed to solve it without using arrays. However, a 20 points bonus will be given to students who solve it correctly using an array (this solution is more efficient then the one that does not uses arrays). |
|
2/12/07 |
In homework #6, question 2, I found a solution without using an array, is it ok? |
Yes, you are allowed to solve it without using arrays. However, a 20 points bonus will be given to students who solve it correctly using an array (this solution is more efficient then the one that does not uses arrays). |
|
23/12/07 |
In homework #9, question 2, why are we requested to write a function with double arguments, when the input is limited to integers? |
You are allowed to receive input from type double (instead of int). Meaning, your program should receive three numbers (int/double) and print them from the smallest to the largest using the function sort3 |
|
24/12/07 |
In homework #9, question 1, I fail to receive input from the user using the following code: printf("enter the first letter\n"); scanf("%c",&i); printf("enter the second letter\n"); scanf("%c",&j); What is my problem and how can I solve it? |
The problem is that when you call scanf("%c",&i) it receives a single character. This means that when you enter the first character and then enter, the second character gets '\n'. The easiest solution would be to replace your code with: printf("enter the first & second letters\n"); scanf("%c %c",&i,&j); |
|
25/12/07 |
In homework #7, question 2, what was the difference between the obligatory and the bonus part? |
In the question one of the requirements is not to CALCULATE a fibonacci series' member more then once. This means that given n, you are allowed to traverse over your array, find the first empty (if n is larger then the calculated values) spot and start from there calculating (and keeping in the array) the rest of the series until n. The bonus is for updating and passing a 'pos' parameter to the function (check my suggested solution). This means that you do not go over the cells that where already calculated in your array! Note that you are entitled for the bonus only if your program works properly, this means that if one have bugs in the obligatory part of the question he will not get the bonus part. |
|
30/12/07 |
In homework #10, when I compile the following code, I get an error: char str[] = "abc"; str++; What is the problem? |
The value of an array variable (the address it is pointing) cannot be changed – unlike pointers! Check tirgul10.ppt slide #10. I advice you to take a look at the detailed example here. |
|
31/12/07 |
Are we obligated to submit all homework assignments? |
Yes. If you have a specific problem, please contact Amitai. |
|
31/12/07 |
In homework 10, question 2 are we allowed to use [] to access the auxiliary string? |
Do not use [] to access any string, including your auxiliary string (hint: use a pointer to it). |
|
31/12/07 |
In homework 10, are we allowed to use functions from string.h? |
Of course. You can find a partial list in tirgul10 presentation (toward its end). |
|
1/1/08 |
I get a compilation warning (code C4267) on the line: "int x = strlen(str)" (str is a string), what am I supposed to do with it? |
You can ignore it. If you are curious, you can read about it details here |
|
7/1/08 |
Am I allowed to change a function's list of arguments as defined in the homework (#11 and in general)? |
No! You are not allowed to change the function's definition as presented in your assignments. However, you are allowed to use auxiliary functions that you defined. |
|
7/1/08 |
In homework 11, question 2, are we supposed to get the array from the user or can we just used a static array defined by us in the main? |
You can use a static array that you define, just make sure that you try arrays from both even and odd lengths (and of course, do not forget that the arrays must be sorted). |
|
14/1/08 |
In homework 12, question 2, can we use realloc? |
No (those who haven't heard about it, do not worry - I did not teach it in class). You are supposed to implement the new dynamic memory allocations by yourselves. |
|
14/1/08 |
Regarding realoc (updated) |
Since Amitai told you in class that it is allowed to use realloc, you are allowed to use it. However, I recommend not to use it, since this was the question's purpose. |
Grades
|
Group |
Homework Grades |
|
9:00-11:00 |
|
|
13:00-15:00 |