Computer programming

Disclaimer

The content here is unnoficial, and meant to aid the students enrolled in CS F111, Computer Programming. Please use these materials as they are intended - supplementary learning aids.

Lab 1 Complete Shell (Tran)Script

Video 1 - date, who, cal, man Shell (Tran)Script

Video 2 - pwd, mkdir, clear, cd, ls Shell (Tran)Script

Video 3 - echo, >, >>, cat, cp, mv, rm Shell (Tran)Script

Video 4 - tips for proficiency and speed (and lab marks) Shell (Tran)Script

Lab 2 Complete Shell (Tran)Script

Video 1 - IO redirection refresher Shell (Tran)Script

Video 2 - sort, xinput, wc, head, tail Shell (Tran)Script

Video 3 - Pipes and grep Shell (Tran)Script

Video 4 - Wildcard Problems Shell (Tran)Script

Lab 3

Screencast 1 - Intro to C: compiling, executing

Screencast 2 - HW.c, Linux.c

Screencast 3 - Incremental Development

Screencast 4 - Dates.c

Lab 4

Screencast 1 - Intro to Conditional statements and if-else

Screencast 2 - Switch statements

Lab 5

Screencast 1 - for, while and do-while loops

Screencast 2 - Control statements: break and continue

Screencast 3 - Nested loops

Lab 6

Screencast 1 - Introduction to Arrays

Screencast 2 - Two Dimensional Arrays

Lab 7

Screencast 1 - Introduction to Pointers

Screencast 2 - Pointer Arithmetic

Screencast 3 - Pointers and Arrays

Challenge 1

We received a question about pointers on our slack channel from Tanmay Dixit recently. While the solution has been posted there, it would be nice if you could try this out.

Question: Predict the output of the following code snippet:

            
                #include <stdio.h>

                int main () {
                	int c[3] = {4, 5, 6}; // an array is basically a pointer to the first element
                	void *d = c; // cast int* to void*
                	d += 1; // increment the void pointer
                	printf("%08x\n", *((int *)d));
                }
            
            

Now run it and see if you got the answer correct. Here is a simulation you can run that explains the output. (Download the gist, compile with gcc simulation.c -w and run with ./a.out.)

If you have a better or simpler simulation, please leave a comment on the gist link.
If you would like to help build future screencasts, message @kaivalyar or @garvit_gupta on slack.

Lab 8

Screencast 1 - Introduction to Functions

Screencast 2 - Call by value, Call by reference and Arrays as parameters

Lab 9

Screencast 1 - Introduction to Recursive Functions

Screencast 2 - Some examples of Recursive Functions

Lab 10

Screencast 1 - Introduction to Strings

Screencast 2 - strcpy(), strcmp() and Segmentation Faults

Screencast 3 - strlen(), strcat(), strstr() and atoi()