Download Borland C++ Compiler For Free

Borland C++ compiler is used to compile and run C and C++ program on windows platform. Borland C++ compiler was lunched after Turbo C++ compiler and has better features then it. Unfortunately the latest version of borland C++ doesn’t come up with an IDE, so we will use one IDE named as C Free to write and run our programs easily. In this article I am sharing the link to download Borland C++ 5.5 and the steps to install and make it work.

Steps to Download and Install Borland C++ 5.5 Compiler

1. First of all download the zip file from the link http://sh.st/a8Ykg

2. After extracting it you will get two things Borland and C Free.

3. Now copy the Borland folder in C drive and after that install the C Free IDE.

4. After finishing the installation just open the IDE. It will automatically detect the borland C++ compiler.

5. Now just write and run your C and C++ programs. You can see in below image I have written and run a simple C++ program using it.

Download Borland C++ Compiler For Free

It is very old compiler so I will suggest you to use some modern compiler like GCC. You can download it from here. If you are facing any problem in downloading and installing Borland C++ compiler then you can comment below.

Arrays in C (Array of Pointers and 3D Array) - Part 7

In this tutorial I will tell you about two topics i.e. array of pointers and 3D arrays. So without wasting any time lets head on to the first topic of this tutorial.


Array of Pointers in C

As I told you earlier “Array is a collection of elements of similar data types”. We have already created array of integer, floats and so on. So one question that arises. Can we make array of pointers? Well the answer is yes, of course. To make an array we have to fulfil just one condition i.e it should contain elements of same data type. So we can store pointers of isolated variables inside an array. Lets take one example to understand this.


#include<stdio.h>

int main()
{
 int *a[4]; //declaration of array of pointers
 int x=23,y=54,z=65,p=45,q;

 a[0]=&x;
 a[1]=&y;
 a[2]=&z;
 a[3]=&p;

 for(q=0;q<4;q++)
  printf("%d ",*a[q]);

 return 0;
 
}


Output
23 54 65 45 

Explanation
  • In the beginning of the program I have declared a 1D array of pointers with size 4. It means it can store addresses of four isolated pointer variables.
  • After that I have declared some integer variables and I have stored some values in it.
  • Now I have stored the addresses of integer variables inside array of pointers a.
  • In the last I have printed all the values at the addresses stored in that array by using for loop.

Note: We can even store the addresses of other arrays inside array of pointers.


3D Array in C

As the name suggests these are arrays having three dimensions. Generally a programmer rarely use 3D arrays. They are mostly used for some game programming. So I will only give you an overview about that.


Declaration and Initialization of 3D Array

Lets take one example to understand it.

int a[2][2][2]={
{
{13, 56},
{54, 67}
},
{
{64, 87},
{23, 678}
}
};

In C language, 3D arrays treated as a collection of 2D arrays. In the above example we can also say that we are creating two 2D arrays. An example of 3D array is given below which is also a combination of three 2D arrays.

Arrays in C (Array of Pointers and 3D Array) - Part 7
3D Array in C - Image Source

Memory Allocation of 3D Array

Allocation of memory of 3D array is similar to 2D array. As the elements inside 3D array always stored in contiguous memory locations.

Arrays in C (2D Array) - Part 6

As I told you earlier the concept of arrays is very closely related to pointers. Arrays will work faster by using pointers rather than using a subscript. So it is always recommended to access arrays by using pointers. In the last tutorial I gave a brief overview on 2D arrays in C. Today I will discuss the usage of 2D arrays with pointers. This is one of the most complex topics of C programming, so I would like to suggest you to read this tutorial with full concentration.


2D Arrays with Pointers

A 2D array is nothing but a combination of 1D arrays. To prove my point I would like to show you an example.


#include<stdio.h>

int main( )
{
 int s[4][2]={
   {542,43},
   {154,354},
   {432,54},
   {435,435}
   };
 int x;

 for(x=0;x<=3;x++)
  printf("\n Address of %d th 1-D array = %u",x,s[x]);

 return 0;

}


Output

2D Arrays with Pointers

Explanation
  • In the beginning I have declared a 2D array with 4 rows and 2 columns and also initialized it. So we can say that this 2D array is a collection of four 1D arrays having 2 elements each.
  • After that I have declared integer variable x which will act as a loop counter.
  • Now I have started the for loop with one printf() function. Consider carefully the arguments in printf() function. I have given two arguments which are x and s[x].
  • As you can see I am only accessing the 2D array with one dimension. So it will give the addresses of only 1D arrays. s[0] will show the address of first element of first 1D array, s[1] will show address of first element of second 1D array and so on.

Access 2D Array Using Pointer Notation

The best way to learn it is through a program.


#include<stdio.h>

int main()
{
 int s[4][2]={
   { 542, 43 },
   { 154, 354 },
   { 432, 54 },
   { 435, 435 }
   } ;
 int x;

  printf(" %d\n",s[2][1]);
 printf(" It will give you address of 1st element of 3rd 1D array - %u \n",s[2]);
 printf(" It will give you address of 2st element of 3rd 1D array - %u \n",s[2]+1);
 printf(" Value at that address %d \n", *(s[2]+1));
 printf(" Alternate way of accessing that address %d \n",*(*(s+2)+1));

  return 0;
}

Output

Access 2D Array Using Pointer Notation

Arrays in C (2D Array) - Part 5

Till now I told you about the 1D arrays but today I will discuss about the 2D arrays or two dimensional arrays in c. Array is a collection of elements with similar data type. We can make arrays with any dimension. However programmers rarely go beyond 3D arrays. I will also give you an overview on 3D arrays in the subsequent tutorials. But today lets discuss the 2D arrays briefly.


2D Arrays in C

As its name suggests, 2D arrays are the arrays having 2 dimensions. Those two dimensions are generally called rows and columns. 2D arrays are also called matrix.


Declaration of 2D Array

A two dimensional array can be declared in following way.

int a[3][3];

This is a 2D array with 3 rows and 3 columns. The total elements in the array are 9 (3x3).


Initialization of 2D Array

Similar to 1D arrays, a 2D array can also be initialize at the time of its declaration. Given below are some of the initialization methods that are used very frequently.

int num[3][2] = {
{43,56},
{56,54},
{65,98}
};

This is one of the simplest way of initializing a 2D array.

int num[3][2] = {43, 56, 56, 54, 65, 98};

This method will also work but it will decrease the readability of the array too.

int  arr[ ][3] = { 12, 34, 23, 45, 56, 45 } ;
int num[][2] = {
{43,56},
{56,54},
{65,98}
{87,86}
};

It is optional to provide the row dimension of a 2D array if we initialize it. Remember giving column dimension is always compulsory.

Lets take one simple program to understand 2D array in C.


#include<stdio.h>

int main()
{
 int student[6][2];
 int x;

 for(x=0;x<6;x++)
 {
  printf(" Enter roll no. and marks\n ");
  scanf("%d %d",&student[x][0],&student[x][1]);
 }

 for(x=0;x<6;x++)
  printf("\n %d %d",student[x][0],student[x][1]);

 return 0;

}

Output

Arrays in C (2D Array) - Part 5

Explanation
1. In the first statement I have declared the 2D array with name student. Remember 2D array also stores elements with index 00. Elements will be stored in this way.

00 01
10 11
20 21
And so on.

2. Now by using two for loops I have stored the values inside 2D array and display it on the screen.

3. Consider carefully the printf() and scanf() function with arguments “&stud[x][0], &student[x][1]”. We are storing and accessing values inside 2D array by row wise. We can also store values and access them column wise too.


Memory Allocation of 2D Array

2D arrays also stores its values similar to 1D arrays. They also store elements in contiguous memory locations.

Elements of first row will be stored first, after that elements of second row will be stored. This procedure will continue until the array elements ends. Given below is the memory allocation of a 2D integer array s[4][2].


Memory Allocation of 2D Arrays

Learn the Effective Guidelines for Coding Standards of jQuery

jQuery can be considered as the library of DOM (Document Object Model) where all the elements can be used after proper selection and manipulation. According to the expert reviews, the attributes like color and visibility and properties like h1 tag can be customized or responded with an event. The event may be a simple mouse click or a huge Javascript command.

Also Read: 9 Useful jQuery Code Snippets That Front End Developer Must Be Aware Of

Learn the Effective Guidelines for Coding Standards of jQuery
Image Source

Standard Guidelines

jQuery.browser or j.Query.support: The browser or the support extension of the jQuery should not be used.

Plug-ins And Options: The plug-ins and the options can be modified any time you want. The options can be converted to .init regardless of the plug-ins.

User Interface Code: You are required to use the ui or the user interface code for all the jQuery events. The keyboard events can be managed through the jQuery.ui.keyCode.

Full Variable Names: The variable names are to be used with the full version and should not be abbreviated. In this process, the bytes will be compressed and therefore saved.

Plug-in State: The plug-in state can be displayed but during the option modification they can never be shown.

Default Values: There must be explicit default values present. In some cases, the null value can be taken as the default. There is no space for undefined.

Alphabetical Orders: The alphabetical order can be grouped at the bottom of each event. The default values can also be specified according to the sequence of alphabets.

Save Plug-In: The plug-ins can be saved for future use. But if any other instance except the plug-in is specified, then you do not require saving the data.

HTML Instead Of XHTML: You are required to use the valid HTML codes like <div> and </div>. Any invalid input like < div/> can throw up a lot of errors in your system.

Elements As Options 

The elements are required to be considered as the options. They can prove to be an excellent parameter. Therefore the DOM elements and the array of the elements can be specified before finalizing the options. You need to ask whether the set of parameters can be passed to the function or there is a common purpose that will set your functions by default.

Manipulate DOM 

The Document Object Model (DOM) can be manipulated using various methods. Before the manipulation process, the existing element can be extracted and it can again be added after the whole process. The concatenation process of the string can be activated with a performance comparison. The elements that are absent from the jQuery model should not be taken into account.

Also Read: 15 Best jQuery Plugins to Make Responsive Design Easier

Handle Events 

All the events are required to be handled in a proper manner. Each page should use the single document handler and not the multiple ones. As the anonymous functions are difficult in debugging, the handlers should be free of it. The in-line JavaScript and the handler can be used in the initial setting up stage. The HTML mark ups cannot be used as they attract the bugs and the debugging process also gets affected. The namespace can be customized and the events can be bound together. If you have multiple elements, the event delegation process can be used in the module. The listener of the single event can be connected to a parent event with all the descendants.

Effects and Animations 

The over usage of animations and effects can be a barrier in your process. If the UX requirements are there you can use the animations by implementing the functionality in a restrained manner. The duration of the animations can be ‘slow’, ‘fast’ or ‘medium’ according to your requirement.

There are also different widgets that can help to run the coding process successfully. The default must be taken as null value and therefore the DOM elements can function properly. To know more visit site http://bigdropinc.com/

Arrays in C - Part 4

Read: Arrays in C - Part 3

In the last tutorial I told you about the memory allocation for arrays. If you are still not comfortable with that topic then I would suggest you to go through that tutorial at least once to understand this tutorial. Today I will tell you about the usage of pointers with arrays. As I said earlier pointer works faster in accessing elements of arrays then by accessing using its subscript. For convenience programmers generally adopt the subscript method but for making an efficient program it is always recommended to make use of pointers.


Note: This tutorial is all about programs, so I will give some good examples to explain the topic. Now I am assuming you are comfortable with the basic C language statements, so I will not explain about them explicitly.



Access Array Elements using Pointer

#include<stdio.h>

int main( )
{
 int x,*y;
 int nums[]={4,53,44,785,124};
 
 for(x=0;x<5;x++)
 {
  printf("\naddress=%u",&nums[x]);
  printf(" element=%d",nums[x]);
 }

 printf("\n");
 y=&nums[0];

 for(x=0;x<5;x++)
 {
  printf("\naddress=%u",y);
  printf(" element=%d",*y);
  y++;  /* Pointer is incrementing */
 }

 return 0;
}


Output

Arrays in C - Part 4

Explanation
  • First of all I have declared an integer array with name nums. The size of the array is five elements. I have also declared an integer variable x and an integer pointer y.
  • After that I have used two for loops. In the first one I have printed the elements and address of each element of the array.
  • Now after the first for loop I have assigned the address of first array element into an integer pointer y.
  • In the second loop I am displaying the address of array elements and its values by using that integer pointer y.
  • To access all the values inside an array I am incrementing the integer point continuously within loop.

Points to Remember

  • Now with the above program I have again verified that array elements are always stored in contiguous memory locations.
  • With the second for loop, consider carefully that an integer pointer y always points to the next element after incrementing it to 1 (this is one of the core concept of pointers in C).
  • To access all the values we have used y integer pointer with printf() function.

What we have learnt?

With the program we have learnt that we can access the whole array by using pointers if we know the base address or address of first element of array.


Another way to get the base address of an array

#include<stdio.h>

int main()
{
 int x;
 int nums[]={4,53,44,785,124};
 printf(" address of first element %u",&nums[0]);
 printf("\n another way to get the address of first element %u",nums);

 return 0;
}

Output

Arrays in C - Part 4

Explanation
With the above program we conclude that we can also access the base address of an array by just typing its name.

Arrays in C - Part 3

Read: Arrays in C - Part 2

So far I told you about some basic topics of arrays in C like initialization of arrays, accepting elements in array, printing the values from an array and so on. Today I will tell you about one advance use of arrays like passing the values of arrays to a function. It can be done in two ways, call by value and call by reference.


Passing Array Elements to a Function

Call by Value

Lets straight away starts with one program.


#include<stdio.h>

void printarr(int);

int main()
{
 int x;
 int nums[]={43,54,64,56,65};
 for(x=0;x<5;x++)
  printarr(nums[x]);

 return 0;
}

void printarr(int n)
{
 printf ("\n %d",n) ;
}

Output

Arrays in C - Part 3

Explanation
  • I have declared an integer array nums and inserted 10 elements into it.
  • After that I have started one for loop. Inside the loop I have written one statement i.e. printarr(nums[x]). It will call the function printarr().
  • At first the value of x is 0. Then the first element of nums array will be passed to the printarr() function.
  • That value will be received in the formal argument n of the function. After that it will display the element on the screen with printf() function.
  • Now the control again moves to the main() function. The printarr() function is again called and second element of array nums is passed to it. This process will continue until the loop stops executing. And at last the program will stop.

Call by Reference 

Lets understand it with one program.
#include<stdio.h>

void printarr(int*);

int main()
{
 int x;
 int nums[]={43,54,64,56,65};

  for(x=0;x<5;x++)
  printarr(&nums[x]);

  return 0;
}

void printarr(int *n)
{
 printf("\n %d",*n) ;
}

Explanation
  • The code of the program is almost similar to the previous one. But in this case we are passing the address of array elements to the printarr() function.
  • Note that I have passed the address of array elements with the help of address of operator i.e. &.
  • The address of the array element is received by an integer pointer variable n.
  • And in last I have printed the value by using printf() function. The output will be same as previous program.


Which one is better?
As you can see both the approaches are giving the same results. However I need to do little modifications in each program. Remember that the second program is better than the first one. Because it is using the pointer. Usage of pointer decreases the execution time of program. This is the reason people use to prefer pointers while using arrays in C.

Arrays in C - Part 2

Read: Arrays in C - Part 1

In the last tutorial I gave you an overview of arrays in C and I also told you about the declaration and initialization of arrays. Till now we have also completed the topic to print the values of array on the screen. Today I will tell you about how to take values inside an array by user. So lets start it with some program.


#include<stdio.h>

void main()
{
 int x[5];
 int i;
 printf(" Enter the values in an array\n ");

 for(i=0;i<5;i++)
 {
  scanf("%d",&x[i]); //taking values inside an array
 }

 for(i=0;i<5;i++)
 {
  printf("\n %d ",x[i]); //printing values on the screen
 }
}

Output

Arrays in C - Part 2

Explanation
  • In our program I have declared “x” as an integer array with 5 elements.
  • By using a for loop I have taken 5 values from the user.
  • Consider carefully the subscript I have used inside scanf() function which is x[i].
  • Almost similar loop is used to print the values inside that array.

To easily understand the working of arrays you should know about the fact.

How array elements are stored in memory?

Consider the below declaration of an array.

int x[8];

When compiler detects some array declaration then it immediately reserves the space for it. In our case I have declared the integer array with 8 elements. When compiler detects it, it will immediately reserve 16 bytes in memory (2 byte for each element). In our case we do not initialize the array with its declaration so it will contain some garbage value by default. The reason behind the garbage values are due to its storage class. By default array has “auto” storage class.

Array consists of contiguous memory locations. It means all the values inside an array will be stored in contiguous memory parts. Checkout the below figure.

Arrays in C - Part 2

Bounds Checking

Consider the below code

int x[8];
x[10]=98;

The size of our array is only 8 elements. But we are storing the value 98 at 10th location. How is it possible? Its certainly not possible. But remember for this situation the compiler will not obstruct you by giving some error. It will not give any warning to you. Because there is no bounds checking is done in arrays. Compiler never checks the limit of the array while storing the values.

So where will this value be stored?
It can be stored anywhere. Probably just after contiguous location of the array. Or top of the array. It can stored anywhere. And remember sometimes small mistakes like that can completely ruin your program and can even hang computer. So I would strongly suggest you to remember this mistake while storing values inside an array.

Arrays in C - Part 1

In the last two tutorials I told you about the preprocessor directives. Today I will start giving you some advance lessons in C programming. And these tutorials starts from Arrays. So in this tutorial I will tell you about the arrays in C and its use. Lets start it with one basic question.


What are Arrays in C?

An array is a collection of similar type of data. Remember here similar means it belongs to one data type. Array is generally used to store many values which belong to one data type.


Why Array is used?

Till now we have some very basic programs. Suppose when we have to make a program to store the marks details of one student. Then we can easily make it by using simple variables. But when we asked to store details of 100 students then it will be very tedious task. We have to take a lot of variables to store those values. And that will be not an efficient way.

In those cases array is used quite easily. It provides an opportunity to store all the values in single array with single name. So we can easily call and receive data with single name.


Declaration of Array

int x[10];

In our above code int is the data type of an array. “x” is the variable name (array name in our case). “[10]” is something new. Well it defines the size of array. “10” means that this array will store 10 integer values in it. Square brackets shows that it is an array. We can create array of any other data type also. Some more examples are given below.

Examples

char a[5];
float b[15];


Initialization of Array

We have declared an array. Now its time to initialize it or storing some values in it. We can do it at the time of its declaration.

int x[5]={1,5,3,5,6};

or

int x[]={5,6,3,5,5};

In the first statement I have initialized the array with five values. And in the second statement I have initialized it without defining the size of an array. Remember when we declare and initialize the array at the same time then mentioning the size of array is optional.


Accessing Array Elements

Subscript is used to access the specific position element inside an array. Subscript is also known as index.

Remember that a subscript or index always starts with 0 end at n-1, here n is the maximum size of the array. If there is an array of size 10 then its subscript will be from 0 to 9.

For example if we want to access fourth element of the array x that we have declared above then it can be done in following way.

int a=x[3];

See here for accessing fourth element we are using index 3 because the subscript or index starts from 0. In the same way for accessing fifth element we will use index 4 i.e. x[4].


Printing Data of Array

Now it’s a perfect time to build our first program which will print all the values of an array.

#include<stdio.h>

void main()
{
 int x[5]={33,66,43,63,67};
 int i;
 for(i=0;i<5;i++)
 {
  printf("%d\n",x[i]);
 }
 
}


Output

Arrays in C - Part 1

Explanation

The program is almost self explanatory. But note down the few points.
  • I have declared an integer array x at the beginning and I have initialized it with some values.
  • Now I have used a for loop to print the values inside it.
  • Remember, subscript of array always starts with 0. So I have initialized variable i with 0.
  • Now I have used x[i] in printf() function to print each value on the screen.

Preprocessor Directives in C - Part 2

Read: Preprocessor Directives in C - Part 1

In the last tutorial I told you about some preprocessor directives which are macros and file inclusion. Two more preprocessor directives are left which I will complete in this tutorial.

So today I will tell you about the two preprocessor directives in C language which are
  • Conditional compilation
  • Miscellaneous directives

Conditional Compilation

The usage of this preprocessor directive is similar to its name. It is often used to exclude some set of statements through the process of compilation. One question which will hit on your mind.

Why should I write those statements which I don’t want to compile?
  • Well programmers often write programs for some clients. Suppose at one stage client demands the older version of program which you have deleted. Then at those cases it is used very widely. So it is often used to omit the working of certain functions easily without touching the code. It is safest way to remove certain code from the program.
  • It is also used to test the working of program. While writing complex C programs it is quite often that the C program gives wrong results at last moment. So we can use conditional compilation to rectify errors by using hit and trial method.
  • Portability is one of the main feature which is quite famous these days. With the use of conditional compilation we can also make the program portable.

Now lets take one example to explain the conditional compilation.

#ifdef MACRONAME
   Statement 1;
   Statement 2;
   And so on…
#endif

It means the statements 1, 2 and so on will only work when a macro is defined in the program with MACRONAME. You can also use #ifndef, it is just opposite of #ifdef. Here #else can be used to show else part of #ifdef or #ifndef. #endif shows the end of conditional compilation preprocessor directives.


#include<stdio.h>

int main()
{
 printf(" Hello! Lets learn conditional compilation");

 #ifdef WORK
  printf("This will not work");
 #endif
 
 return 0;
}

Output

Preprocessor Directives in C - Part 2

Explanation
  • As you can see, the second printf() does not work. Its because we have not defined any macro with WORK.
  • To make the second printf() work, I just have to add #define WORK before main() function. After that it will also print the message inside second printf().

Miscellaneous Directives

The two preprocessor directives that are not commonly used falls inside the category of miscellaneous directives.

1. #undef
2. #pragma


#undef

This preprocessor directive is generally used to undefine certain macros at some stage. It is not commonly used but we can undefined any macros by using #undef followed by the macros name.


#pragma

This preprocessor directive is generally used in three ways which are 

a. #pragma startup
b. #pragma exit
c. #pragma warn

#pragma startup: This is used to call some function right from the start up (before executing main() function). We can call any function by using this preprocessor directive.

Syntax: #pragma startup funcall

In the above code “funcall” function will be called from the start up of the program.

#pragma exit: It is a counter part of start up. It is used to call some function when program ends.

Syntax: #pragma exit funcall

In the above code “funcall” function is called at the exit of the program.

#pragma warn: This preprocessor directive is used very rarely. It is generally used to supress a specific warning inside a program.