Web Test

For online website test

Showing posts with label Programming. Show all posts

C Program to search and delete in a singly Linked List

No comments :
delete node from linked list
Delete a node in a singly linked list just like a person breaks away from a human chain then the two persons (between whom the person was) needs to join hand together to continue the chain. We use free keyword to delete a node from linked list, first finding the node by searching in the linked list and then calling free() on the pointer that containing its address.





1. How to delete a node from linked list:

If you wish to delete head (first) node from linked list, you need to assign 'head' node to a 'temp' node and changeing the head node with next node then calling free(temp) to delete the node. If you wish to delete tail (last) node from linked list, you need to assign 'tail' node to a 'temp' node and changeing the tail node with previous node then calling free(temp) to delete the node. If you wish to delete node is any node other than the head and tail node then you need to changing the 'next' pointer of the previous node with the address of the node that is just after the deleted node.
Also Read: C Program to Search and Insert in a singly Linked List

2. C programming code to search and delete in a singly Linked List:

You need to create a linked list before search or delete node in a linked list.To know, how to create and display node in a linked list, just follow the link which is given in below:
Also Read: C Program to Create and display Linked List

2.1. Code to search in a Linked List:


2.2. Delete searched value in a linked list:


2.3. Source Code to Create, Search, insert and display a Linked List:


3. Download Source Code to search and delete node in a Linke List

Download source code to Create, Search, Insert and Display a singly Linked List from below link:
Download source code to Create, Search, insert and Display a linked list

Try this code, i am sure you will be able to delete searched value in a singly Linked List. If you have any problems about this code, then write your problems in below, we will try to solve your problems. Don’t go in a hurry, if you enjoyed this article, please subscribe to feeds and drop a comment to show your thought.


C Program to Search and insert in a singly Linked List

No comments :
Blog-commenting-sites-list
Linked List is a dynamic data structure whose length can be changed (increased or decreased) at run time. Linked list located at random memory location. To search and insert in a linked list, we use user defined function for search and insert a node in a linked list.




C programming code to Search and insert in a singly Linked List:

You need to create a linked list before search or insert in a linked list.
Also Read: C Program to Create and display Linked List

1. Code to search in a Linked List:


2. Insert before searched value in a linked list:


3. Insert after searched value in a linked list:


4. Source Code to Create, Search, insert and display a Linked List:


4. Download Source Code for Linke List

Download source code to Create, Search, Insert and Display a singly Linked List from below link:
Download source code to Create, Search, insert and Display a linked list

Try this code, i am sure you will be able to Search and insert in a singly Linked List. If you have any problems about this code, then write your problems in below, we will try to solve your problems. Don’t go in a hurry, if you enjoyed this article, please subscribe to feeds and drop a comment to show your thought.


C Program to Create and Display Linked List

No comments :

Create and display linked list
Linked List is a dynamic data structure whose length can be changed (increased or decreased) at run time. Linked list located at random memory location. To create a linked list, malloc must be used for dynamic memory allocation and struct keyword to create data structure ( Such as Node). Node is a one kind of data structure which has two parts. One is data or information(such as array) and another is reference or link(such as pointer). In a singly linked list, first node known as Head and last node known as Tail. Reference part of a tail node must be NULL for singly linked list.



C programming code to create and display singly linked list:


1. Code to Create Linked List:


struct node
{
int data;
struct node *next;
}*head=NULL, *last;
/*Node (above code) must be define after the heading and before the main function) */

struct node *new_node;
char ch;
do
{
new_node=(struct node *)malloc(sizeof(struct node));
printf("\n Enter the data:");
scanf("%d",&new_node->data);
new_node->next=NULL;
if(head==NULL)
{
head=new_node;
last=new_node;
}
else
{
last->next=new_node;
last=new_node;
}
fflush(stdin); /*You may use it to remove flush effect if any*/
printf("\n To create again press any key, if not press Space.\n");
ch=getch();
}
while(ch!=32);// 32 use for Space

2. Code to Display Linked List:


struct node *temp;
if(head==NULL)
printf("\n Linked List is empty.");
else
{
printf("\n\t Linked List:\n\t-------------\n\n");
temp=head;
while(temp!=NULL)
{
printf("\t=>\t%d\n",temp->data);
temp=temp->next;
}
}

3. Source Code to Create and Display Linked List:


//Code by ismail@programmer.net
#include
#include
#define Esc 27
struct node
{
int data;
struct node *next;
}*head=NULL,*last;
void create();
//------------------------------------
int main()
{
char ch;
while(1)
{
printf("\n\n <@> Main Menu <@>\n ******************\n");
printf("\n\t1.Create Linked List\n\t2.Display.\n\tPress ESC to Exit\n");
printf("\n Please choose, what kind of work you want to do?");
ch=getch();
switch(ch)
{
case '1':
create();
break;
case '2':
display();
break;
case Esc:
exit(1);
return 0;
default:
printf("\n\n Invalid Input/ choice.");
}
}
return 0;
}
//-------------------------------------------------
void create()/*Function to create a node or insert a node at last */
{
struct node *new_node;
char ch;
do
{
new_node=(struct node *)malloc(sizeof(struct node));
printf("\n Enter the data:");
scanf("%d",&new_node->data);
new_node->next=NULL;
if(head==NULL)
{
head=new_node;
last=new_node;
}
else
{
last->next=new_node;
last=new_node;
}
fflush(stdin); /*You may use it to remove flush effect if any*/
printf("\n To create again press any key, if not press Space.\n");
ch=getch();
}
while(ch!=32);// 32 use for Space
}
//---------------------------------------------
void display()
{
struct node *temp;
if(head==NULL)
printf("\n Linked List is empty.");
else
{
printf("\n\t Linked List:\n\t-------------\n\n");
temp=head;
while(temp!=NULL)
{
printf("\t=>\t%d\n",temp->data);
temp=temp->next;
}
}
}

4. Download Source Code for Linke List

Download source code to create and display singly linked list from below link:
Download source code to create and display linked list

Try this code, i am sure you will be able to create and display singly linked list. If you have any problems about this code, then write your problems in below, we will try to solve your problems. Don’t go in a hurry, if you enjoyed this article, please subscribe to feeds and drop a comment to show your throught.


You will create a calculator without any software......

No comments :
You will create a calculator without any software......কেমন লাগবে যদি আপনি নিজেই একটি ক্যালকুলেটর বানিয়ে ব্যাবহার করতে পারেন......খুব মজা তাই না। যদি তাই হয় তাহলে আসুন এবার বানিয়ে ফেলি নিজের ক্যালকুলেটর নিজেই, তাও আবার কোন সফট্‌ওয়্যার ছাড়াই।
 প্রথমে আপনি start menu হতে notepad open করে
নিচের কোড টুকু লিখুন অথবা কপি পেস্ট করুন। তারপরে File>>save as এ গিয়ে my calculator.bat নামে & Save as type হতে all Files সিলেক্ট করে Desktop এ সেভ করুন, আতঃপর বানানো ফাইলে ডাবল ক্লিক করে উপভোগ করুন নিজের তৈরি ক্যালকুলেটর ।


  @echo off

    color 4A

    title MY CALCULATOR

    :loop

    cls

    echo created by Ismail Hossen Rana

    echo _

    echo email:ismail@programmer.net

    echo web: www.ourpcsolution.blogspot.com

    echo.

    echo My Calculator

    echo ———————————————–

    echo * = MULTIPLY

    echo + = ADD

    echo – = SUBTRACT

    echo 2 = SQUARED

    echo / = DIVIDE

    echo After an equation, type CLEAR to clear the screen of your equations, type KEEP to leave them there, or type EXIT to leave.

    :noclear

    set /p UDefine=

    set /a UDefine=%UDefine%

    echo.

    echo =

    echo.

    echo %UDefine%

    echo KEEP, CLEAR, OR EXIT?

    set /p clearexitkeep=

    if %clearexitkeep%==CLEAR goto loop

    if %clearexitkeep%==KEEP echo. && goto noclear

    if %clearexitkeep%==EXIT (exit)

    :misspell

    echo.

    echo ———————————————–

    echo You misspelled your command. Please try again (make sure you are typing in all caps LIKE THIS).

    echo Commands:

    echo CLEAR Clear all previous equations and continue calculating.

    echo KEEP Keep all previous equations and continue calculating.

    echo EXIT Leave your calculating session

    echo Enter in a command now.

    set /p clearexitkeep=

    if %clearexitkeep%==CLEAR goto loop

    if %clearexitkeep%==EXIT (exit)

    if %clearexitkeep%==KEEP goto noclear

    goto misspell



সবাই ভাল থাকুন আর পাসের মানুষটিকেও ভাল থাকতে সহায়তা করুন । প্রযুক্তির সন্ধানে-পিসি সলুশানের সাথেই থাকুন ।
                 আল্লাহ হাফেজ !!!