Welcome!

Letusdesign.blogspot.com is still under construction. You are welcome to see the partially constructed blog. 

However, we are working hard to make this blog a complete guide to web design and programming. You can subscribe to this blog using the form linked here.
This will help you keep updated about this blog, free ebooks (that we shall launch soon) and all the free resources that we publish here.

I would also request you to please help us spread a word about this blog. Please

 Like us on facebook




Let Us Design
on Google+





You mean a lot to us. Our effort and blog without YOU is like body without its soul.... :)

Google Docs - What can be done?

Google is on go...creating numerous FREE products that has are extensively useful for all of us. One such such product is Google Docs. Launched with the purpose of handling the documents...it eventually developed as online software that can handle all the basic works of Microsoft office. In this post we are going to enlist uses of Google docs:

Google Docs can be use to:

  • store files online
  • share files and documents
  • create office documents
  • create presentations,spreadsheets, drawings and tables.
  • create forms such as contact forms.
  • convert office documents into PDF, RTF,ODT, Text, Word, HTML
  • create new PDF
  • embed your file to webpage.
Effectively Google has almost eliminated the use of Microsoft Office and PDF readers and PDF creators.

Basics of Functions


C programs that we learnt till now were relatively small, easy and had less logic. So we could easily write entire program. But at times we may need to perform same operation at various different parts of program and logic can be too difficult and "heavy" to understand if written within the main() function. In such instances we use functions.

What is a function?

  • Function is a block in C program that consists a logic or statements that are to be executed.
  • We divide entire program in the form of blocks called "functions" so that we can understand it C program becomes easy to write as well as understand.
  • For example, within the C program we need to find averge of three numbers at different parts of program. Insted of writing the program to find average of three numbers we can simply use function to do that operation

main() is also a function

main() itself is a kind of function. It is the function that is executed first. Other functions are called within the main function.
Note : We can call one function within another function, other than main function.
See the video below to undestand calling of function.

Example of a function:

#include <stdio.h>

void trial(); /*function prototype declaration*/
void main()
{
trial(); /*calling of function*/
printf("Hope I will learn C soon");
}

void trial() /*function definition*/
{
 printf("I want to learn C");
}

Now here we have defined two functions: main() and trial(). Execution of program will begin with main().

void trial() is second line of the program means that function will not return any value. you can find more about return statement here. void word tell the compiler that function won't return anything.

trial(); written within the main() function is called calling of function. We call the function where we need it to be executed.

A seperate block starting with void () trial is called function definition. Here we tell the complier what the function has to do.

Why should we use function?

One may argue that we can put all the logic in main() function. Why to bother about functions then? But when you will wrtie complex programs it would be difficult ro wite the code in the main() function. Also you may need to wrtie same logic multiple if we dont use functions.
Program written using functions appear more structured. It becomes easier to trace what part of program is doing which function. Also it is easier to trace the error(if any) in the program.

See the following video:



do-while loop

We have already seen while loop for C programs. "do-while" is similar to while loop, except the position of the condition to be tested. If you have not learnt while loop yet, please click here.

If you are done with while loop you would know that, in C programs while loops are used when we know in prior that how many times the loop has to be executed. But what if we don't know how many times do we need to execute the loop? "do-while" is used in such cases.

In do while loop, the logic portion is executed once even if condition becomes false at first test itself. This can be easily understood from syntax given below.  

For loop in C


For loop is most wildely used loop in C program.

For Loops:

  • For Loop is used when a C program or specific part of C program has to be repeatedly executed.
  • E.g when we want to calculate simple interest of five different persons.
  • This loop can be used as a replacement of while loop.
  • Inface For loop is widely used for it better efficieny.

Why For loop is more efficient than While loop?

Syntax of for loop makes it better, easy to use and efficient. In for loop we set a loop counter, test condition and increment/decrement in just one single line. You can compare it with the while loop syntax to understand it easily.


Syntax:

for (initialise counter;test counter;increment operator)

{
statements;
do this;
do this;
/* This portion usually includes logic of program or 
anything that has to be executed repeatedly*/ 
}

More about for loops:

  • Test condition should be such that it should eventually become false, otherwise the loop would be executed FOREVER...indefinitely.
  • Condition being tested may use relational or logical operator.
while(i<=10)
while(i>=10 && j<=15)
while(j>10 &&(b<20 || C>20))
  • Note that for statement does not have ";" at the end.

See the following video:



While Loop in C


While Loops is one of the loops that is used in C program.

While Loops:

  • While Loop is used when we know in prior that how many time the loop has to be executed.
  • E.g when we want to calculate simple interest of five different persons.

Syntax:

while (test loop counter using condition/expression)

{
statements;
do this;
/* This portion usually includes logic of program or 
anything that has to be executed repeatedly*/ 
}

More about while loops:

  • Test condition should be such that it should eventually become false, otherwise the loop would be executed FOREVER...indefinitely.
  • Condition being tested may use relational or logical operator.
while(i<=10)
while(i>=10 && j<=15)
while(j>10 &&(b<20 || C>20))
  • Note that while(test condition) does not have ";" at the end.

See the following video:



Introduction to Loops


In all the C programs that we saw till now, programs used to follow a specific sequence. But in practice we may need to make computer go through same sequence repeatedly. This process is called looping and Loops are used for this purpose.

Loops:

  • Loops are used to repeat same operations or sequence of operations.
  • Loops can be used to repeat entire program or any portion of the program.

Kinds of Loops in C:

  • for statement
  • While statement
  • Do-while statement



C Instruction

Now we have written one simple C program in previous C session. In today's session we shall see the instructions that we give to C. This is important to understand before we start with C programming in full flow manner.

There are basically three types of C instruction:
  • Type Declaration Instructions
  • Arithmetic Instructions
  • Control instructions

Type Declaration instruction is used to declare the type of variables used in a C program.
Arithmetic instruction is used to perform arithmetic operations between constants and variables
Control instruction is used to control the execution of various sequence in a C program.

Control instruction will not be discussed in this session as it will be discussed differently. Click here to see those sessions. However, I would recommend that you should follow the flow.

Type Declaration Instruction

  • Type Declaration instruction is used to declare the type of variables used in a C program.
  • Before we use any variable in the program, it is must for us to declare it at the beginning of main() function.

Arithmetic instruction and operators

  • A C arithmetic instruction consists of a variable name on left hand side of the "=" and constant on right hand sign of "=". 
  • "=" is called assignment operator. 
  • + - * / % are arithmetic operator.
Please see the video below to understand today's session effectively.

Ice Breaking with C - 2

Ice Breaking with C - 1

Basics in C - 2

In this session we shall see rules for constructing integers constants. It may see to you what we are talking about...but you will soon understand everything. You just need to keep the points that we have covered in basics sessions.

Rules for Constructing Integer Constants

  1. An integer constant must have at least one digit.
  2. It must NOT have a decimal point.
  3. It can be positive or negative.
  4. By default, integer is assumed to be positive.
  5. No commas or blanks should be used within the integer constant.
  6. Allowable range is -32768 to 32767
Range actually depends upon the compiler. Above mentioned range is for  16 bit compiler like Turbo C++ that we are going to use. For 32-bit compiler the range would be much greater. But we shall start with most basic compiler and then grow.



Rules for Constructing Real Constants

  • Real constants are also called floating point constants.
  • Real constants are written in two ways - Fractional form and exponential form.
Following rules should be observed while constructing real constants:
  1. A real constant must have atleast one digit.
  2. It must have a decimal point.
  3. It can be positive or negative.
  4. Default sign is positive.
  5. No commas and blanks are allowed within a real constant.
To understand the exponential form please see the video below:

Rules for Constructing Character Constants

  1. It should be a single alphabet or symbol enclosed within single inverted comma. E.g 'A'
  2. Maximum length of character constant can be one character. So 'AB' is INVALID.

Basics in C - 1



1) The C character Set


"A character is any alphabet,symbol, digit which is used to represent information." Each programming language has a set of valid character that it can understand. Following table shows valid characters in C



2) Constants and Variables

 

It is a time to recall your algebra class. Digits like 1,2,3.... whose value remains constant are called constants.
Whereas we used alphabets like x,y,z are called variables
  • Constants : It is a entity that does not change.
  • Variables : It is the entity that does change.

3) Types of constants



C constants can be divided into two types:

  • Primary constant
  • Secondary constants


See the figure below:


These basics are must for you to understand so that you can perform your programming easily and effectively.