Advertisement

  • Topic 6: The While Loop
    The while loop continues to loop while some condition is true.
    When the condition becomes false, the looping is discontinued.
    Look ate the program:


























    1. Here an integer "count" is declared.
    2. The count is given initial value 0.
    3. The while loop>>>here until the value of 'count' is less than 6 the loop continues.
    4. Then count is incremented.

    After while loop the statements below it executes.
    In the first case the value is initial value ie, '0'.
    Then the while loop executes successfully as '0' is less than '6'.
    The 'count' is incremented by one (count = count + 1;).
    From here the control goes back to while loop as these are enclosed inside while loop.
    The value of 'count' becomes 1.
    This is continued until the value becomes 6.
    and so the program runs and produce results as shown in the figure.

    more
  • Topic 5: To Print Some Numbers
















    Look at the program.

    here each time you assign the values the previous value is replaced and new values are considered from the following steps.
    Here also we are using code::blocks to do the program.
    Please don't ignore these simple programs and do them along with me.
    These simple programs hold great logics.

    more
  • Topic 4: Another Program With More Output

    This is nothing different from the other program..just that we have more outputs in this one.



























    Here we are using code blocks to do the program other than the old Dev C ++.
    This one is more advanced and easy to use..
    Get it from here

    more
  • Topic 4: My First C Program
    Now lets go to our first program...
    to print 'Hello World' on the screen..!
    Type the following into the DevC++
























    1. Save it as helloworld.c
    • spaces are not allowed in the c program name
    • we can use ( _ ) underscore instead
    2. Compile and the execute the program


    Explaining Each Elements In The Program


    1. Header Files

    #include<stdio.h>
    #include<conio.h>

    C contains several predefined operations in its header files.
    So when we use #include<>;

    It includes the suite of


    Header files that are already in the directory


    The preprocessor replaces the line #include with the system header file of that name. More precisely, the entire text of the file 'stdio.h' is replaced for #include

    don't confuse.. if it feel confusing skip...

    stdio.h - standard buffered input/output (used for printf(), cin, cout ..)

    conio.h - console input and output (used for clrscr(), getch()..)
    .

    2. Commenting

    Two methods..
    • // Your comment here....... (only single line)
    • /* Your Comment Here.....*/ (from starting /* to the closing */)
    The compiler just ignores the content typed like this...
    You can type anything here..



    3. Main Function

    Every C program has a primary (main) function that must be named main
    The main function serves as the starting point for program execution.
    A program usually stops executing at the end of main,
    although it can terminate at other points in the program for a variety of reasons.

    void main()

    void indicates that the method doesn't return any value (can discuss later..)


    4. The Printf Statement

    The printf is used to print text or other contents on the screen
    Let's look at some variations to understand printf completely. Here is the simplest printf statement:

    printf("hello..");

    This call to printf has a format string that tells printf to send the word "Hello" to standard out.

    The following line shows how to output the value of a variable using printf.

    printf("%d", b);

    The %d is a placeholder that will be replaced by the value of the variable b when the printf statement is
    Often, you will want to embed the value within some other words.

    Lets see something for fun..

    printf("The temperature is ");
    printf("%d", b);
    printf(" degrees\n");


    An easier way is to say this:

    printf("The temperature is %d degrees\n", b);


    5. The getch()
    GETCH stand for Get Character. It holds on till it get a keystroke, otherwise the program will execute, produce results and exit at once.


    Output:

    The program should run and produce result like this..




















    Best Of Luck..

    more
  • Topic 3: Acquainting With The Bloodshed Dev C++

    Downloading

    Click on this and save the file somewhere, such as your desktop.

    Installing

    Hit all the next buttons.

    Creating a Project

    To write a program, you have to make the source code files. To do this you create a project.

    To create a project you go to File > New > Project.





    A dialog will come up asking you what kind of project you would like to
    make, what you would like to name it, and if you want to compile in C++ or C.
    Here i choose empty project and c as my compiler
    Compiling and Executing



    Compiling and executing a program is very simple. You can hit F9 to compile
    and execute or click the button, Or you can do it from the Execute menu

    more
  • Topic 2: Syllabus for the 'C' Language Course.


























    1a) Historical introduction to the Language.

    b) Demonstration of a very simple program.

    c) Brief explanation of how the computer turns
    your program text into an executing program.

    d) The basic differences between 'C' and other languages.
    The advantages and disadvantages.

    We make the assumption that you are able to turn on your machine,
    use the Operating System at the Control Line Interpreter prompt
    "$ ", "c:>" or whatever, and to use an editor to enter program text.


    2 a) How the 'C' language arranges for the storage of data.
    An explanation of the keywords associated with data.
    The storage classes:- static auto volatile const.
    The variable types:- char int long float double
    The meaning of:- signed unsigned

    b) Introduction to the concept of pointers.

    c) Explanation of reading from the keyboard and writing to the screen.
    i.e. printf and scanf, the print formatted and scan formatted functions.

    d) The use of arguments to the main() function, argc argv env.

    e) A simple program to format text.


    3 Structures, arrays and pointers.

    a) Explanation of more coplex data structures.
    b) Programs which demonstrate uses of pointers.

    4 The operators of the language, arithmetic, pointer, logical, bitwise.

    a) Precedence.
    b) The unique bit and shifting operators.
    ( for a high level language )

    5 a) The Preprocesser.
    b) Header files

    What they are and what you put in them, both your own and
    those provided by the 'C' compiler vendor.

    A simple title which includes all sorts of things,
    both very useful and a number of traps.

    6 The library, why we have them and some of the more useful routines.

    a) How to read the book.
    b) The string functions as an example.

    7 a) Mistakes and how avoid making them.
    b) Debugging strategies.
    c) The assert macro.

    8 a) More on the representation of data vis. struct, typdef.

    b) Tables of all sorts.
    Arrays of structures.
    Pre-initialisation of data structures.
    ( Including jump or dispatch tables )
    The bit-field.

    c) Use of header files in this.


    9 a) The control structures of the language, what (not) to use and when.


    10 File IO

    This is an enormous subject and we we will
    really only just scratch on the surface.


    11 Lint, and more on errors / bugs and how to avoid them.


    12 The stack and a quick dip into assembler

    A study of the function calling mechanism used by most 'C'
    compilers and the effect on compiler output code of using
    the register storage class and the optimiser.

    13 The heap.

    The 'heap', it's management, malloc(), calloc() and free().


    14 Portability Issues.

    a) Defaults for storage sizes.
    b) 'endianism'. Yes, there are big-endian and little-endian computers!
    c) Functions which can be called with a variable number of arguments.


    15 Sample programs.

    Much is to be gained from examining public domain packages
    examining the code and reviewing the author's style.
    We will look at a number of functions and complete packages.
    in particular we will examine a number of sorting functions,
    a multi-threading technique, queues, lists, hashing, and trees.

    more
  • Topic 1: What is C






















    What is C??


    C is a programming language originally developed for developing the Unix operating system. It is a low-level and powerful language, but it lacks many modern and useful constructs.

    Do I need to know math??

    Not too much... Most of programming is about design and logical reasoning, not about being able to quickly perform arithmetic, or deeply understanding algebra or calculus.

    What do I need to start??

    You will need a program called a compiler, which will turn the text of your program into something your computer can run.

    more

Advertisement

Advertisement