Sunday, February 12, 2012

Job Switch - Day 1

It was a good Sunday morning when i woke up. Started the day with a hot morning tea.

Now, update on today's plan:
1. Read first 10 questions of C-faq.
        Read first 3 only and then realized, it is not the way to learn C. May be it help for temporary purpose when i have an interview on next day and i just want to revise some good  questions. But anyways, during the course of day, i finished up reading 7 of them. :)
2. Make 3 basic programs in C.
        Task achieved. I have created 3 programs. Learnings from them follows.

Good Learns:
1. Use \n at the end of each line of debugs or printf.
2. scanf, printf - what they take and what they return. - to do
3. scanf - if u give some string with scanf, it will not ignore it and may include those also with the % arguments. So no use of giving extra information in scanf. Instead use printf to print to console.
4. so what are % arguments called - format specifiers. :)
5. TRUE - 1, FALSE - 0 if u use relational operators ('==', '<', '>' etc.).
6. = is also an operator (operates from right to left). So, a=b=c; will copy the value of c into b and then value of b into a (i.e. both a and b will be equal to c after the expression).
7. arguments to a function can be expression also, but they will be executed first before passing the values.
8. what happens when printing(using printf) a variable with data type different from the format specifier?
9. what if i don't give any argument to while loop? - compilation error. The argument or controlling expression is required for while loop which is not try in case of for loops.
10. Use of math library functions with gcc: They will not work as required if you don't use the -lm option to ask gcc to link the math library function.
11. Scanf - format specifier for double is %lf (see it as long float), similarly for long %ld.

Overall, I should say it a good start. Hope, it will be continued.

I am using the following link to get on the ideas and then use google for my rest of the queries.
http://www.eskimo.com/~scs/cclass/notes/top.html