Library

Course: Programming in C - The Complete Course

Programming in C - The Complete Course

  • Life Time Access
  • Certificate on Completion
  • Access on Android and iOS App
About this Course

This course is guaranteed to make the students fall in love with programming. Easy to learn methodology used by a seasoned teacher who has been teaching programming in different computer languages for the last 20+ years.

Flood gates for a lucrative career in programming are certain to open for those Who undergo this course diligently and passionately.

I assure you that if you complete this course it will pave a way for you to become a consummate programmer as all the advanced programming languages and technologies are based on C only. There won;t be any looking back once you immerse yourself with all the contents.

In future I will be posting assignments also . I will come up with more courses like Java and PHP etc.

My humble advice: 

Write all the programs by yourself typing. Make changes here and there and see the changes in output. Play with the code. Don't get discouraged with errors as they are your teachers. 

Basic knowledge
  • The only prerequisite is the ability to handle very basic operations of a computer although no prior experience in programming is required. Download any free IDE (Integrated Development Environment) for C language like Dev-C++ - Bloodshed, Code::Block, Netbeans etc. These softwares are used to write and execute your C (C++ also) programs. All of them are free. Just google and download from their official websites. Dev-C++ - Bloodhsed is highly recommended as I used it in the whole course
What you will learn
  • The students will start solving programming problems. They will be in a position to pursue their courses in advanced languages and technologies like C++ , Java , Android , iOS, PHP, Python etc.This will enhance students' understanding with regard to the way software applications are developed. The students will definitely develop a huge interest in programming and software development
  • Be prepared to take notes of the programs I explain, on a paper notebook before writing the programs directly on your computer. This is a great and proven method to learn programming. Please do away with copy and paste habit while undergoing this course
Curriculum
Lectures quantity: 86
Common duration: 08:58:18
Listen in before you take a plunge
  • Introduction to the course  

    I have left no stone unturned to make this course the best in the market. But my extremely serious advice to learners - Write the programs on your own. The only way to learn programming is by writing , trying , modifying the code. Errors and their removal will definitely ibring the best in you. This course will teach you from basics upto some advanced topics.Starting from scratch you will learn what a programming language is. You will move on to learn data types , variables , programming construct (sequence, selection and iteration) , working with arrays (single and double dimensional) , how to develop your own functions,pointers, pointer arithmetic, representation of arrays through pointers,structures with and without pointers, file handling etc. All the topics are explained with the help of slides followed by appropriate example programs. I will keep uploading more lectures once this course kick off. suggestions and criticism will be received with thanks as this will help me to strive more to make this course more useful.  

  • Profile of Instrcutor  
  • What you are going to learn - Curriculum  
Having the first brush
  • Basic concepts of programming languages and Life cycle of a C program  

    A program is in fact a set of instructions i.e. programming statements. Programming languages are a medium to write these programs. Three type of categories are there for programming languages - 

    1. Machine language 
    2. Assembly languages
    3. High level languages
    • Machine language program is directly machine readable hence needs no conversion.
    • Assembly language is a compromise between machine language and high level language. Even though these programs do not use machine codes but use a special symbols called mnemonics. In order to convert an assembly language program into machine language we need assemblers. 

    The program written by the programmer in a high-level language is termed as 'Source program' which passes through the stages of pre-processing, compilation , linking and loading. The source program written in a high-level language is in an English like language. The compilation of the source program is a must as it converts into machine language which is understandable to the computer machine.There are two translation techniques to convert a high-level language program -

    1. Interpreters
    2. Compilers


  • Structure of a C program  

    A program is essentially made up of functions. A function is a subprogram that performs logically isolated task.Function main() happens to be the entry and exit point of the program. Library functions are the in-built functions that come with the language software itself and user-defined functions are developed by the programmers themselves. 

    An IDE (Integrated Development Environment) is the software that provides all the facilities of writing , editing , compiling and executing the program under one umbrella.

  • Character set, tokens, Data types, I/O library functions  

    This lecture contains explanation of character set of c language. Various types of tokens (constants,variables,keywords,operators) , data types in C language and a brief description of formatted and unformatted input out functions.

    • A character set is nothing else but all the characters put together which will be used while writing a C program. 
    • Any programming statement is made up by using tokens (constants, variables, keywords and operators).
    • There are 32 keywords in C language. They cannot be used as variable names.

    C is a strongly typed language. That means a variable has to be declared in C language before using it. At the time of declaration data type has to be mentioned. Various data types supported in C are - int,unsigned int,long int , unsigned long int, float, double, long double, char. 

Sample programs to get you going
  • Formatted I/O functions printf() and scanf()  

    printf() and scanf() library functions present in the header file stdio.h are indispensable functions for almost all the C programs. Header files are just collections of declarations of library (in-built) functions and macros.There are large number of header files provided in C e.g. stdio.h, conio.h, math.h, stdlib.h, process.h, ctype.h, string.h, graphics.h etc.

    C Programmers use printf() for generating a formatted output on the output screen. They use scanf() for reading the values from the user. To read means to input.

    Format specifiers are sort of codes like %d(%i), %f, %ld(%li), %lf, %Lf, %c, %s, %lu, %u, %x, %o etc. which are to be used with printf() and scanf(). They come in handy while formatting the output. 

  • First Sample Program  

    1) Comments also known as remarks are used to show some lines in your code that explain the task you are doing. C compiler is going to simple ignore comments and remarks at the time of compilation. The purpose of writing comments is just to let a reader of your program know what is happening in this part of the code. They are not meant to be for users as they won't yield any output. Even though it's not necessary to give comments but they come in handy for the learners and other programmers who are perusing your program.

    // is used to write a 'single line' comment whereas multiple lines comments are enclosed within /* and */.

    2) Escape sequences are used mostly within the printf() statement and are used to produce some kind of effects on your output. e.g. \n will show the output on the next line. 

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Second Sample Program  

    A very important fact about printf() statement is - whatever we write within double inverted commas (") that is printed as it is except format specifiers and escape sequences. e.g. 

    1) printf("Meditation course will cost you $%d",fee) ;  // here fee is assumed to be an int variable

    In the above statement "meditation course will cost you $" will be printed as it is as there is no format specifier or escape sequence but in place of %d value of variable fee will be printed. 

    let us assume value of variable fee is 25, then output will be -

    meditation course will cost you $25.

    2) printf("Company is on the hiring spree") ;

    output:

    Company is on the hiring spree.

    3) printf("The following temperatures have been recorded through the day - %f\n%f\t%f",temp1,temp2,temp3) ;

    output:

    The following temperatures have been recorded through the day -

    12.400000

    14.500000         16.880000

    above are just the assumed values of float variables temp1, temp2, temp3.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Difference between getch(), getche() and getchar()  
    • getch() reads a single char but doesn't display the character typed by the user. Doesn't wait for Enter key to submit.
    • getche() reads a single char and displays the character pressed on screen. Doesn't wait for Enter key to submit.
    • getchar() reads a single char and displays the character pressed on screen. waits for Enter key to submit.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Formatting output  

    printf() function is pretty powerful as far as formatting the output goes. e.g. 

    • printf("%10d",x) ; // assumed value of x is 25

    The output will be :    

         25

    %10d will reserve 10 columns and if the number happens to be having number of digits less than 10 , then value will be right aligned. So 25 was printed after leaving 8 blank spaces.

    • printf("%-10d",x) ; // will make the value left aligned. 8 spaces will be left on the right side.
    • printf("%.2f",y) ; // assumed value of y is 12.831458

     The output will be:

    12.83   

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Type casting: Implicit and Explicit  

    Type casting comes in handy when we evaluate expressions involving different data type values. Let me explain the whole idea behind type casting -

    By default when an arithmetic operator (+, -, *, /, %) is applied on two values of the same data type then this yield the output of same data type.That means int and int operands will yield int result, float and float operands will yield float results and so on. 

    1. Implicit type casting
    2. When an arithmetic operator is applied on operands of two different data types, result belongs to the higher data type between the two. Actually data type of the operand with lower data type is promoted to the higher data type. e.g. operation on an int and a float operand will give float result as float data type is bigger.
    3. Explicit type casting
    4. Sometimes both the operands belong to the same data type but we want to have the output with a different data type. Here explicit type casting comes in handy.

    e.g. 

    int a=10,b=7;

    float c ;

    c=a/b ; // only integer part that is 3 will be produced and assigned to c as a and b both have int data type

    but we want to have the output as a float value so that it can be accommodated by float variable c. So following trick that uses explicit type casting will do the job -

    c=(float)a/b ;   // a being type casted as float

    or

    c=a/(float)b ;   // b being type casted as float

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • More Sample programs  

    Two more sample programs with complete explanation to enable students consolidate their understanding in the topics discussed so far.

    • First program reads principal amount, rate of interest and time from the user and then calculates the simple interest. Thereafter it uses printf() formatting feature to display the output.
    • Second program reads marks of a student in 3 subjects and then calculates and prints the percentage in a formatted way. Type casting is also used.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

Operators in C language.
  • Operators in C language - Part I  

    1) operators are symbols that tell the computer what operation is to be performed on operands. Operands mean variables and constants.

    e.g.

    See the following in the expressions - 

    • x+y   here + is the operator applied on operands x and y (variables).
    • 100-4 here - is the operator applied on operands 100 and 4 (constants).
    • 50*6  here * is the operator applied on operands 50 and 6 (constants).
    • k>90  here > is the operator applied on operands k(variable) and 90 (constant).

    2) In this lecture I have discussed the following categories of operators. This categorisation is based upon the type of operations these operators do.

    • Arithmetic operator
    • Relation operators
    • Logical operators

    In the nest lecture we are going to learn more operators.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Operators in C language - Part 2  

    Types of operators ( based upon the number of operands )-

    1) Unary Operators     

    These are the operators in which only one operator is used.

    2) Binary operators

    Thses are the operators which use two operands.

    3) Ternary operators (conditional operator)

    There is only one ternary operator i..e ?: . It operates on 3 operands.

    All the above have been explained fully with appropriate examples in this lecture.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Operators in C language - Part 3  

    Compound Assignment operators 

    +=

    -=

    *=

    /=

    %=

    In the lecture all these compound assignment operators have been explained in full detail along with example code.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Precedence and Associativity of operators - Part I  

    Precedence and Associativity :

    When there are multiple operators in an expression then C has a predefined rule of priority for the operators. e.g. in the following expression * will take place first and then + as * has higher precedence than +.

    d=a+b*c ;

    Watch this lecture fully to have the complete understanding of precedence.

    Please see the description and video of next lecture to know about associativity of operators.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Precedence and Associativity of operators - Part 2  

    We do have many instances whereby many operators have the same precedence level. In that case Associativity plays it's role.when two or more operators bearing the same precedence level appear in a n expression. Associativity is either left to right or right to left.  e.g. in the follow expression sub expression a*b will be evaluated first as * and / have the same precedence level but their associativity is left to right. Afterwards / will operate. + and - have the same precedence level but lower than * and /. Their associativity is also from left to right. Hence - will operate first than +.  

    d=a*b/10-25+100 ;

    I have provided a table of precedence associativity of all important operators in C.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

Sequnce construct and all about if statement programming construct
  • Programming constructs in C - General concept  

    Programming constructs (Control structures) :

    They are the building blocks of any program. Basically there are 3 types of constructs -

    • Sequence                    
    • Selection (decision-making)               
    • Iteration (loops)

    In this lecture I have explained sequence construct with the help of an example. In this example program you will also get to learn more about header files as I have used math.h. This header file contains some useful mathematical function like sqrt() , pow() etc.

    In sequence construct all the statement are executed one after another in a sequential manner without skipping or repeating any statement(s).  

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Programming constructs in C - Using if and if..else statement (Part I)  

    If statement (selection construct) :

    if statement is very powerful yet simple decision making statement. Using this programmer tests a condition. If condition is true a particular action is taken otherwise some other action is taken. By action I mean a statement or a set of statements.

    You will learn using simple if statement and then using if statement with else.

    The whole concept will come clear to you as it has sample program with detailed explanation.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Programming constructs in C - (using nested if) Part 2 (a)  

    The presence of an if within another if is termed as "nested if". This is required when a condition comes out to be true and we want to test another condition.

    The else of inner if appears first and that of outer if later.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Programming constructs in C - (using nested if) Part 2 (b)  

    This lecture just contains another sample program that will consolidate your concept about nested if.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Alternative to nested if  

    In the previous lecture we discussed a program involving nested if. It calculated biggest among 3 numbers.

    In this lecture we will use an alternative way to write that program by using && (conjunction operator) logical operator.

  • Programming constructs in C - (using if..else..if ladder) Part - 1  

    if .. else .. if ladder

    This offshoot of if construct is hugely useful. This mainly comes in handy when we want to write programs that offer a solution for value range problems..

    e.g if I want to calculate income tax (IT) as per the following slabs -

    if income is more than or equal to 10000 then IT is 45%

    if income is between the range   >=5000 and <10000 then IT is 30%

    if income is between the range >=2000 and <5000 then IT is 20% 

    if income is <2000 then IT is 10%

    Ladder will go like this -

    if (income>=10000)

    IT=45.0/100*income ;

    else

    if (income>5000)

    IT=30.0/100*income ;

    else

    if (income>2000)

    IT=20.0/100*income ;

    else

    IT=10.0/100*income ;

    Please refer to the programs explained in the lecture.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Programming constructs in C - (Alternative to if..else..if ladder) Part - 2  
Switch case construct
  • switch case Part - 1  
  • switch case Part - 2  
Iteration construct (Loops)
  • Introduction to loops  

    What are loops ? 

    Loops are used for executing one or more statement repeatedly. A condition is tested and loop statements keep executing as long as this condition turns out to be true.There are 3 types of loops -

    • while loop (pre-tested)
    • do..while loop (post-tested)
    • for loop (pre - tested)

    In pre-tested loops first the condition is tested only then loop statements are executed if condition is true.

    In post-tested loop first the loop statements are executed only then condition is tested.

    Post-tested loop statements are executed at least once.

    The subsequent lectures will take you on an interesting journey into loops. A lot of examples will facilitate quick and tenacious learning. 

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • while loop in action  

    while loop (pre-tested loop) :

    In this kind of loop first condition is tested and if it's true then control enters into the loop. Remember if there are more than one loop statements they have to be enclosed within a curly braces block i.e. { }.Otherwise in case of single loop statement it is optional.

    This lecture will explain the whole process in a very simple manner.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • do..while loop in action  

    do..while loop(post-tested loop) :

    It is a post tested loop in which first loop statements are executed and only after that condition is tested. Remember if there are more than one loop statements they have to be enclosed within a curly braces block i.e. { }.Otherwise in case of single loop statement it is optional.

    Always remember in such kind of loop , loop statements are executed at least once.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • for loop in action - Part I  

    for loop (pre-tested loop):

    It won't be exaggeration if I say that for loop is the most popular loop among programmers. It has 3 components - 

    • initialisation(s)
    • condition(s)
    • increment or decrement statement(s)

    Watch the video lecture which explains the whole working step by step.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • for loop in action - Part 2  

    In this lecture you will learn different ways for loop can be applied. You will learn the behaviour of for loop when it is terminated with a semi-colon(;) and when it is not. 

    You will understand the working of for loop when multiple statements are written in the la ast component of for loop. You will have a fair idea of how we can skip initialisation component. In fact all the 3 components of loop are optional.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • for loop in action - Part 3  

    This lecture will teach you how we can use multiple statements in all the 3 components of for loop  viz. initialisation, condition and increment/decrement part.

    Every aspect has been elucidated in a very easy-to-understand manner. 

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

Honing the programming skills using loops
  • Sample loop programs - Part I  

    This lecture will show you how to write some simple programs using loops like printing odd,even series using all 3 types of loops. This will brush up your knowledge further about loops and their working.

    You will also write and execute a program that prints the mathematical table of a number in a proper format.

     Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Sample loop programs - Part 2  

    In this program user will read (input) a number and program will calculate it's factorial. As you know if want to calculate the factorial of a number n , then following method is applied -

    n * (n-1) * (n-2) * (n-3) * ............* 2

    e.g. if n=7 , then -

    7 * 6 * 5 * 4 * 3 * 2   and output will be 5040.

    Program has been explained with the help of a dry test (dry run). A dry run is just a simple table whereby we display the changing values of variables used in the loop. 

    •  Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Sample loop programs - Part 3  

    This is yet another program that will take you further in understanding the logic build up using loops. In this program a number will be read by the user and it' reverse will be calculated.

    The logic is quite straight forward. Get the remainder of this number by dividing it with 10 using modulus operator %. Print it and get the integer quotient of this number by dividing it with 10.Update the value of this number with this quotient. Go on round the loop until the number becomes zero.

    The whole logic has been elaborated with the help of a dry test in the video. 

    •  Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Nested Loops - Part I  

    Nested Loops : 

    A loop within a loop is called nested loops. Always remember - for each turn of outer loop inner loop is executed some specified number of times.

    In this lecture I have explained this concept with the help of an example. In this example user will read 2 numbers - starting number a and ending number b. Our program will print mathematical tables of all the numbers within this range.

     Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Nested Loops - Part 2  

    To practise nested loops here is another sample program with full explanation about it's logic.

    Here we will learn how to display some patterns using numbers or particular symbols like *. I will be uploading some more such sample programs.

     Note: Do write all the programs yourself. Then make changes here and there and re-execute. 

The concept of arrays and their programming
  • The basic concept of arrays  

    Arrays:

    An array is a finite set of homogeneous elements stored in contiguous memory locations. Homogeneous elements are the values belonging to the same data type.

    An array has to be declared before it's use.

    e.g.  The following declaration is allocating the space for 10 int elements in the memory 

    int arr[10] ;      

    as an int takes up 4 bytes in the memory total 40 bytes will be reserved in contiguous memory locations.

    Moreover we can initialise array elements at the time of declaration.

    e.g.

    double values[ ]={1000.99,9000.85,1000.15} ;

    In the above statement array space for 3 double data type elements will be reserved such that first element values[0] is assigned 1000.99 , second element values[1] is assigned 9000.85 and so on.

    You will learn some other important issues also.

  • Traversal of array elements - Part 1  

    Traversal of array elements :

    As there are multiple elements in an array it's not feasible to traverse them without using a loop. Any of the 3 types of loops can be employed to traverse the array elements one by one. This lecture will show you the whole process whereas array elements are being read(inputted) , printed and processed. 

    Note : At  4.23 I have mistakenly said "loop will break when value of n reaches 11". It's actually as follows -

    "loop will break when value of n reaches 10."

    Note: Do write all the programs yourself. Then make changes here and there and re-execute. 

  • Traversal of array elements - Part 2  

    Another example program to learn how to traverse array elements.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute. 

  • Traversal of array elements - Part 3  

    In this lecture you will learn how the size of an array can be decided by the user and not the programmer.

    e.g.

    suppose we want to declare an array arr with the size n. The value of variable n will be read from the user.

    double arr[n] ;   // here size n is NOT a constant but a variable 

    A Word of Caution :

    Some C/C++ compilers (outdated ones) like Turbo C/C++ do not allow to use a variable as the size at the time of array declaration.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute. 

  • Sorting Techniques : Bubble sort Part - 1  

    Bubble Sort :

    There are innumerable usages of arrays including -

    1) Sorting ->  This technique is used to arrange array elements either in ascending order or descending order.

    2) Searching -> This is the programming technique in which a particular value is searched (found) among the array elements.

    In this lecture you will learn the whole logic applied in applying bubble sort. The logic has been explained with the help of diagrams. You will also learn about interchanging (swapping) of values of two varaibles or array elements.

    In the very next lecture I will show and explain the program of bubble sort. 

  • Sorting techniques : Bubble sort Part - 2  

    In this lecture I have shown and explained the program of bubble sort. In almost all sorting techniques the whole process involves nested loops. Outer loop takes care of passes and inner loop handles the comparisons.

    A pass is nothing else but one of the various stages (phases) that the bubble sort passes through, 

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Double dimensional arrays Part - 1  

    Double Dimensional arrays (2-D arrays) 

    A 2-D array is just a matrix with some specified number of rows and columns. we can safely say that a 2-d array is a collection of many 1-d arrays,

    They come in handy when we want to  register multiple entries for some entities. Suppose we want to store marks of 5 students in 3 subjects each, then we will work using a 2-d array that has 5 rows and 3 columns. Rows will represent students & columns marks.

    while traversing a 2-d array we apply nested loops , outer loop representing rows and inner loop columns.

    The whole procedure has been explained with the help of an example.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute. 

  • Double dimensional arrays Part - 2  

    This lecture covers Initialisation of 2-d array elements and an example program of matrix multiplication.

    e.g.

    float sales[ ][3]={

    {100,200,900},

    {900,100,876},

    {100,200,900}

    };

    Matrix addition is a simple process of adding corresponding elements of two 2-d arrays and putting the result in a 3rd. array.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute. 

Strings in C Language (char arrays)
  • Strings Part - 1  

    String :

    A string is in fact a char array last character of which is null terminator. A null terminator is a non-printable character having ASCII value 0. This is used to mark the end of a string. It is represented with \0.

    There are many library functions to deal with strings. They are present in the header file string,h.

    1) strlen() -> returns the length of a string. It does not count null terminator.(\0)

    2) strcpy() -> copies one string into another. It takes two arguments. First is the target string and second is the source string.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Strings Part - 2  

    More about strings functions :

    1) strcat() -> is used to concatenate (join) 2 strings.

    2) strrev() -> to reverse a string.

    3) strupr() -> to convert a string into uppercase (capital letters).

    4) strlwr() -> to convert a string into lowercase (small letters).

    Listen carefully the distinction between strupr(),strlwr() and toupper() ,tolower() .

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

Pointers
  • Basics of pointers  

    Pointers :

    They say that your knowledge about C is incomplete without knowing pointers. Hence I have elaborated them very painstakingly in the lectures.

    A pointer variable is in fact a special variable that does not store ordinary value but memory addresse of other identifiers (variables, arrays etc.). 

    You will be explained fully what exactly is a pointer variable. Diagrams have been used to bring home the point. The syntax of declaring pointer variables has been discussed in detail.

    Small code snippets will make the things clear. Operators associated with pointers will be learnt viz. & (address of operator) , * (value at address operator) and **(pointer to pointer operator). 

  • Pointers in action Part - 1  

    Pointers in action : 

    Here you will get a practical hand on pointers. An example will show you how to declare and store addresses into pointer variables. You will learn usage of  %u format specifier to print  the addresses. The usage of pointer to int , pointer to float , pointer to char will be explained.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Pointers in action - Part 2  

    Pointers in more action :

    * is called 'Value at address' operator and comes in handy when we want to print the value of a variable using it's pointer.

    e.g.

    int *pt1, a=100 ;  // decl. of pointer to int

    double *pt2, b=19000.00 ;  // decl. of pointer to double

    pt1=&a ; pt2=&b ;

    printf("%.2lf\t%d", *pt2, *pt1) ;  // will print 19000.00 and 100 respectively 

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Pointer to pointer  

    Pointer to pointer :

    As a pointer variable is also a variable , hence it takes up space in the memory. Then of course it will have a memory address too. 

    A pointer to pointer variable stores the memory address of yet another pointer variable.   

    ** operator comes in handy while declaring a pointer to pointer operator.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Pointer Arithmetic  

    Pointer Arithmetic :

    Programmers have the liberty to use + and - arithmetic operators with a pointer variable. But these operators quite differently when applied on a pointer variable.

    Let's assume that there is a variable var stored at address 8081.This address is stored in a pointer variable pt.

    see the code snippet below -

    int *pt ; 

    int var=100 ;

    pt=&var ;

    ++pt ; // will make the value of pt 8085 and NOT 8082.

    The following statement would have made the value of pt as 8077.

    --pt ; 

    The reason behind this is when some value k is added to a pointer variable then it adds as follows -

    sizeof(datatype) * k

    In the above example it was -

    sizeof(int) * 1

    As you know sizeof(int) would return 4. in this case multiplication with 1 is optional as we are adding only 1.

    Now you can easily gauge what would happen when --pt is executed.

    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Subtracting two pointer variables  

    Subtracting two pointer variables :

    This lecture fully explains what happens when two pointer variables are subtracted.

    Remember we can only subtract two pointer variables. No other arithmetic operator viz. + , / , * etc. is allowed. 


    Note: Do write all the programs yourself. Then make changes here and there and re-execute.

  • Arrays and Pointers  

    An Array Name is pointer to base address:

    When we declare an array, a pointer variable with the same name as the array name is automatically created in the memory. This pointer variable is assigned the base address of this array. Base address is the memory address of the very first element of array.

    Hence an array name is actually a pointer to base address.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Dynamic Memory Allocation Part - 1  

    Two Types of memory allocations are there -

    1) Static memory allocation -

    In this type of memory allocation the space for identifiers (variables,Arrays,structures etc. is allocated at compilation time. That connotes that amount of space is fixed when the program is compiled. It means each time the program is executed same amount of memory will be used.

    Note: User running the program cannot either contract or expand the fixed amount of allocated memory space.

    2) Dynamic Memory allocation -

    In this type of memory allocation the space for identifiers is allocated at run-time i.e. when the program has been pushed into the execution stage. User running the program can either contract or expand the size of previously allocated memory space.

    In C language malloc() and calloc() library functions are used. It's highly advisable to go for malloc() rather than calloc() as malloc() has no restrictions on amount of memory space allocation.

    Note: In some C compilers (old ones) programmer needs to include header file alloc.h but not needed in modern compilers.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Dynamic Memory Allocation Part - 2  

    In this lecture I have explained the use of a very powerful library function called realloc() . Using this function programmer can re-allocate the size of a previously allocated amount of memory space.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
Functions
  • Basics of functions  

    Basics of functions:

    A function is a subprogram that performs logically isolated task.If there are n number of functions in a programs , each of them will be operating on a different kind of logic.

    Function are categorised in 2 categories -

    1) Library function (in-built functions)

    These functions come shipped in with C compiler. There are umpteen library functions so they have been put into different container files called header files. There are many header files like stdio.h ,conio.h , math.h , stdlib.h , string.h , ctype.h , bios.h , graphics.h etc.

    2) user-defined functions:

    These functions are written and maintained by the programmer himself.

    This complete course has a very elaborate coverage on user-defined functions in this section.

  • Developing Functions , A practical approach Part - 1  

    Developing functions: Part 1:

    Here come the nitty-gritty of practical aspects of functions. Students will be having a hand-on practice on how to apply 3 important parts of a function viz. .-

    1) function prototype (declaration)

    2) function calling (invoking a function)

    3) function body (function definition)

    All these aspects will be put across to you in a very detailed manner using a sample program.  

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Developing functions , A practical approach Part - 2  

    Developing functions: Part 2

    You will be taken through a practice session. Some more sample programs will solidify your concepts about development of functions.

    I will be writing some programs like passing a number to a function and calculating and returning it's factorial. Another program will show you how to pass principal amount, rate of interest and time to a function and that will calculate and return it's simple interest. 

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Developing functions , A practical approach Part - 3  

    Developing functions:Part 3

    In this lecture you will learn the fact that some function need not return any value. Such functions are callsed void functions.

    Some example programs  will bring home the point. 

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Scope of variables in functions Part - 1  

    Scope of variables Part - 1:

    Always remember that a variable or any identifier declared within the body of a function is strictly local to it. Now that connotes that this variable is not accessible to other functions.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Scope of variables in functions Part - 2  

    Scope of variables Part - 2:

    Always remember that a variable or any identifier declared within the body of a function is strictly local to it. Now that connotes that this variable is not accessible to other functions.

    If we have two functions with two variables with the same name, they do not coincide with each other. 

    e.g.

    if a function abc() has a variable declared with the name age and another function xyz() has a variable with the same name i.e. age , both will be maintained separately in the memory and changin oe will not have bearing on the other.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Working with global variables  

    Global variables:

    A global variable is accessible in all the functions definitions of which are written below it's declaration. Always remember there is only a single copy of a global variable irrespective of the number of functions using it.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Name clashing of local variables Vs. global variables  

    A local variable is given precedence if it's name is same as a global variable:

    e.g.

    float price=100.0000 ; // global variable

    void check()

    {

    float price=10000.0000 ; // local to function check()

    printf("%.2f",price) ;  // will print 10000.00 and NOT 100.00

    }

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Some facts about return statement  

    using return statement we can not return more than one values.

    e.g.

    return a,b,c,d ;

    will return only d [as comma operator(,) has the associativity from right to left.] 

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Calling a function by value  

    Call by value:

    When we pass the passing arguments (actual arguments) in a normal fashion this is called "call by value". In this case we are actually passing the copies of values of actual arguments. Hence when the formal parameters are changed in the called function , the changes do not reflect back on actual arguments in the calling function. 

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Calling a function by reference  

    Call by reference:

    When we pass memory addresses of passing arguments (actual arguments) to a function this is termed as "call by reference". This comes in handy when we want our actual arguments to be changed when we make changes through formal parameters. Apparently formal parameters in this case ought to be pointer variables as they will be capturing addresses.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Passing an array to a function  

    Passing an array to a function:

    Passing an array to a function is a typical example of call by reference. Why ? Because you learnt in one of the previous lectures that "an array name is pointer to base address". Hence when we simply pass an array name to a function we are in fact passing the address of the very first element (known as the base address).

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
Recursion
  • Recursion (Recursive functions) Part - 1  

    Recursion Part - 1:

    Recursion is arguably one of the complex topics in programming. Recursion is the state when a function calls itself. That connotes that calling and called functions are the same. You will see a simple example program and understand the basic niceties of recursive functions.

    The next lecture will take you through a more complex program that involves recursion.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Recursion (Recursive functions) Part - 2  

    Recursion Part - 2:

    Recursion uses the concept of a data structure called 'stack'. Simply put , a stack is an array that follows the principle of LIFO (Last In First Out). All the statements written after recursive call will not be executed forthwith rather all the following statements till the return statement are put on a stack. When recursion stops these statements are picked one by one in a LIFO manner and executed. That means the statement that was put last on the stack will be executed first and so on.

    I have explained the whole working with the help of a diagram. 

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
Command Line Arguments
  • Command Line Arguments Part - 1  
    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Command Line Arguments Part - 2  
    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Command Line Arguments Part - 3  
    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
Structures in C language
  • Basics of structures  

    Basics of structures:

    A structure is a finite set of heterogeneous or homogeneous elements stored in contiguous memory locations. Please note that structures are different from arrays as arrays can store only homogeneous elements.

    Elements of a structure are also called members.

    • Watch the full video for understanding the whole concept.

    Help of diagrams has been taken to make you understand in an easy manner.

  • Creating a structure and accessing it's members  

    Creating a structure:

    You will learn the practical aspect of structures. In fact there are two main components :

    1) structure specification

    2) declaration of structure variable(s).

    structure specification merely contains the declarations of all it's members. Interestingly no space is allocated at this time,

    Space is allocated for the structure(s) as soon as declarations of structure variables take place.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Working with multiple structures  

    Working with multiple structures:

    In the previous example you learnt how to declare a structure variable (also called structure) and accessing it's members. But mostly we need to have more than one structures. 

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Pointer to structure  

    Pointer to structure:

    As a structure variable (or simple called a structure) is stored in RAM and of course does have an address. Now this memory address can be stored in a pointer variable veritably called 'pointer to structure'.

    In this case instead of using dot (.) member access operator programmer will use arrow operator (->).

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Array of structures  

    Array of structures :

    More often than not programmers need to have multiple structures. It's very cumbersome to declare many structures variables with  different names and work on them. Here comes the beauty of array of structures. An array of structures is just an array which consists of many structures stored in contiguous memory locations. 

    It becomes pretty easy to traverse these structures by applying loops.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Alternative method of declarations of structures  

    Alternative method of declaring structure variables, array of structures and pointer to structure:

    This short lecture will just take you through an alternative method of declaring structure variables, pointers to structures and array of structures.

    e.g.

    struct laptops

    {

    int RAM ; float cpu_speed;

    };

    struct laptops lvar ;

    The above statements can be alternatively written as :

    struct laptops

    {

    int RAM; float cpu_speed ;

    } lvar ;

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Passing a structure to a function  

    Passing a structure to function:

    This is an excellent facility using which programmer can pass a whole structure to a function. We will pass only one structure variable and the formal parameter of .called function will capture it.

    Please note that this lecture covers passing a structure to a function using call by value. I will present an example of passing a structure by reference.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Passing a structure to a function using call by reference  

    Passing a structure to a function using call by reference: 

    We can pass a structure variable using call by reference (i.e. passing it's address). The formal parameter in this case ought to be a pointer to structure. 

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
File handling in C
  • File Basics : Using fputc() to write on a file  
    • What is exactly file handling ?:

    You will find full explanation on the concept of files. I have used diagrams liberally to bring home the point.

    • Writing single char at a time on a disk file:

    fputc() comes in handy when programmer is required to write on a file character by character.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Using fgetc() to read from a file  

    Reading from a file one character at a time:

    fgetc() does the opposite of fputc() learnt in previous lecture. It reads data from a file character by character.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Using fprintf() and fscanf() to write and read multiple values on/from a file  

    Writing multiple values of different data types on a data file: 

    If programmer is willing to write multiple values of different types on a file then he can use fprintf() function.

    Reading multiple values from a file and assigning them to variables:

    using fscanf() function programmer can read multiple values from a file and assign them to various variables.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
  • Using fwrite() and fread() to write and read structures on/from a file  

    Writing structures on a data file :

    Using fwrite() function we can conveniently write a whole structure on a file. This is the most practical approach in file handling techniques as a structure is just a record. The records (structures) are written on a binary file.

    Reading values from a file and assigning them to a structure:

    Using fread()  function we can read multiple values from a data file and assign them to a structure.

    Both fwrite() and fread() go hand in hand.

    • Watch the full video for understanding the code.
    • Note: Do write all the programs yourself. Then make changes here and there and re-execute.
Reviews (1)
3 days before