Computer Programming – A wonder!!!

A program is a set of step-by-step instructions that directs the computer to do the tasks you want it to do and produce the results you want.

There are at least three good reasons for learning programming:

  • Programming helps you understand computers. The computer is only a tool. If you learn how to write simple programs, you will gain more knowledge about how a computer works.
  • Writing a few simple programs increases your confidence level. Many people find great personal satisfaction in creating a set of instructions that solve a problem.
  • Learning programming lets you find out quickly whether you like programming and whether you have the analytical turn of mind programmers need. Even if you decide that programming is not for you, understanding the process certainly will increase your appreciation of what programmers and computers can do.


A set of rules that provides a way of telling a computer what operations to perform is called a programming language. There is not, however, just one programming language; there are many.

 

HTML – Script Tag

In HTML, a script is a small, embedded program that can add interactivity to your website. For Example, we can create dynamic web pages, make image rollovers for really cool menu effects, or even we can also validate the data on your HTML forms before users submit their information.

HTML script element either contains a client side script or refers to the URI containing a client side script in an HTML document.Now, two very popular scripting languages that are commonly used in HTML to make web pages come alive are JavaScript and VBScript .

HTML Script Syntax:-

Scripts are often placed within the <head> element. This ensures that the script is ready to run when it is called.

HTML – Entities

In HTML, “entity” is just a attractive name for “symbol”. Here, we cannot use the less than (<) or greater than (>) signs or angle brackets within our text. Instead, they need a special characters. So, to display these special characters, they must be replaced with the character entities.

Here, is the list of special chracters:-

Result

Description

Entity Name

non-breaking space

&nbsp;

<

less than

&lt;

>

greater than

&gt;

&

ampersand

&amp;

quotation mark

&quot;

apostrophe

&apos;

¢

cent

&cent;

£

pound

&pound;

¥

yen

&yen;

euro

&euro;

©

copyright

&copy;

®

registered trademark

&reg;

trademark

&trade;

C – Error Handling

C does not provide direct support for error handling (also known as exception handling). It returns -1 or NULL in case of any error and set an error code errno. It is set as a global variable and indicates an error occurred during any function call. Usually, developers should set errno to 0 at the time of initialization of the program. A value of 0 indicates that there is no error in the program. Therefore,  programmers can check the returned values and can take appropriate action depending on the return value.

Generally, at the time of dividing any number, programmers do not check if a divisor is zero and finally it creates a runtime error. So, it is good practice to check it to avoid runtime error.

It is a common practice to exit with a value of EXIT_SUCCESS in case of program coming out after a successful operation. Here, EXIT_SUCCESS is a macro and it is defined as 0.

Angular Js – Tables

In angularjs if we want to show data in table formats, directive ng-repeat is used to draw table easily. It will loop through the array data objects in the DOM elements and help us to show data in tables.

Syntax for table:-

//    <tr ng-repeat=”user in users”>

<td>{{user.name}}</td>

<td>{{user.age}}</td>

<td>{{user.location}}</td>

</tr>  //

Here, we used angularjs ng-repeat directive to loop through users object to bind values to each row in table.

In this, we can do the following styling with the table in angularjs applications:-

  • Change the style of the table.
  • Sort table columns with order by filters.
  • Bind Tables.

Simple Example of table:-

 

//    <style>

table, th , td {

border: 1px solid blue;

padding: 5px;

}

table tr:nth-child(odd) {

background-color: #f2f2f2;

}

table tr:nth-child(even) {

background-color: #ffffff;

}

</style>

 

<table>

<tr>

<th>Name</th>

<th>score</th>

</tr>

<tr ng-repeat = “subject in student.subjects”>

<td>{{ subject.name }}</td>

<td>{{ subject.score }}</td>

</tr>

</table>

Try this, and learn more at onlinecodesample.wordpress.com

C – Pointers

A Pointer is a variable that holds address of another variable of same data type. Pointers are used everywhere in the C language. A program can store and manipulate the value stored using variable’s identifier. When we declare a variable in C, compiler reserve space in memory to hold the value assigned to this variable.

We can access the value of this variable either by variable identifier or by directly accessing the memory location using pointers. Every memory location is given a unique address. Therefore, a pointer variable is nothing but a variable that contains an address, which is a location of another variable. Value of pointer variable will be stored in another memory location.

Advantages of Pointers-

  • It reduces length of the program and its execution time.
  • We can return multiple values from function using pointer.
  • It makes you able to access any memory location in the computer’s memory.

Symbols used in Pointers-

Symbol Name Description
& (ampersand sign) address of operator determines the address of a variable.
* (asterisk sign) indirection operator accesses the value at the address.