Showing posts with label C Programming. Show all posts
Showing posts with label C Programming. Show all posts

Sunday, 1 September 2013

How To Reverse An Integer In C


Here is a program for reversing the number.
First take the number as an input which you wanna reverse.
Then a while loop,which will continue as long as the number is greater than 0.
In the while loop the number is divided by 10 and the remainder is saved in the integer rem.
The value in the rem is printed.
And the number is divided by 10,the result is saves in integer num which can only save the int value so the floating point value will be discarded.
For Example
num=12345
In while loop : 12345%10=5
rem=5
12345/10=1234   ------Because the integer can not save floating point value.
This loop will continue until the whole number is reversed.
The last result will be 54321

Monday, 20 May 2013

Queue Through Link List

A queue is somewhat differs from the stack.It is also a container of data but follows the FIFO(First In First Out) principle.
In queue, the insertion takes place from the rear of the queue and the removal from the from the front of the queue.For Example,you may have seen a line of people to pay their bills on the billing counter.What happens there is that the person who is on the front of the line, pays his bill and leave that space.Whereas the people keep coming and stand in the line for their turn from the back of the line.This is the same pattern of the queue.
Insertion of element is known as Enqueue and removal is known Dequeue.
Here is a Queue program implemented through link list.

DOWNLOAD QUEUE THROUGH LINK LIST

Stack Through Link List

A stack is a container in which objects are removed and inserted according to the principle of LIFO(Last In First Out) principle.
 Objects can be inserted less than the limit of the stack,but the removing is done only from the last element. Inserting an item is known as "Push" and removing an item from the stack is known as 'Pop'.
 A stack works like a books in the shelf.You can insert books in the shelf but can only remove the books from the top that is the last book inserted. Here is a program implementing stack in C++.

 DOWNLOAD STACK IN C


Friday, 12 April 2013

Link List In C(Doubly)


Doubly-linked list(DLL) is a sophisticated kind of linked list. In Doubly Link
List, each node has two links:
one points to previous node and one points to next node. The previous link of
first node in the list points to a Null and the next link of last node
points to Null.

Now Here is the link to download the doubly link list.
You can download and learn how a doubly link list works.

DOWNLOAD

Link List In C


Link list are made up of nodes,in which each node points or refers to the next node in the list.In addition, each node contain a unit of data that can be called as cargo which store the data to be stored on the link list.
As the last node of the link list does not need reference to any node so the last node points to or refers to null.
So here is the code for the link Singly link list having only one node which contain reference of the next node.
Download this program from below link

DOWNLOAD