SlideShare a Scribd company logo
Implementation in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
struct node
{
Int data;
Int key;
Struct node *next;
};
Struct node *head = NULL;
Struct node *current = NULL;
//display the list
Void print List ()
{
Struct node *par = head;
Print ("n [“);
//start from the beginning
While (par! = NULL)
{
Print ("(%d, %d) ", par->key, ptr->data);
Par = par->next;
}
Print (“]");
}
//insert link at the first location
Void insert First (int key, int data)
{
//create a link
Struct node *link = (struct node*) mallow (size of
(struct node));
Link->key = key;
Link->data = data;
//point it to old first node
Link->next = head;
//point first to new first node
Head = link;
}
//delete first item
Struct node* delete First ()
{
//save reference to first link
Struct node *Templin = head;
//mark next to first link as first
Head = head->next;
//return the deleted link
Return Templin;
}
//is list empty
Bolo is Empty ()
{
Return head == NULL;
}
int length()
{
int length = 0;
struct node *current;
for(current = head; current != NULL; current = current-
>next)
{
length++;
}
return length;
}
//find a link with given key
struct node* find(int key){
//start from the first link
struct node* current = head;
//if list is empty
if(head == NULL)
{
return NULL;
}
//navigate through list
while(current->key != key){
//if it is last node
if(current->next == NULL){
return NULL;
}else {
//go to next link
current = current->next;
}
}
//if data found, return the current Link
return current;
}
//delete a link with given key
struct node* delete(int key){
//start from the first link
struct node* current = head;
struct node* previous = NULL;
//if list is empty
if(head == NULL){
return NULL;
}
//navigate through list
while(current->key != key){
//if it is last node
if(current->next == NULL){
return NULL;
}else {
//store reference to current link
previous = current;
//move to next link
current = current->next;
}
}
//found a match, update the link
if(current == head) {
//change first to point to next link
head = head->next;
}else {
//bypass the current link
previous->next = current->next;
}
return current;
}
void sort(){
int i, j, k, tempKey, tempData ;
struct node *current;
struct node *next;
int size = length();
k = size ;
for ( i = 0 ; i < size - 1 ; i++, k-- ) {
current = head ;
next = head->next ;
for ( j = 1 ; j < k ; j++ ) {
if ( current->data > next->data ) {
tempData = current->data ;
current->data = next->data;
next->data = tempData ;
tempKey = current->key;
current->key = next->key;
next->key = tempKey;
}
current = current->next;
next = next->next;
}
}
}
void reverse(struct node** head_ref) {
struct node* prev = NULL;
struct node* current = *head_ref;
struct node* next;
while (current != NULL) {
next = current->next;
current->next = prev;
prev = current;
current = next;
}
*head_ref = prev;
}
main() {
insertFirst(1,10);
insertFirst(2,20);
insertFirst(3,30);
insertFirst(4,1);
insertFirst(5,40);
insertFirst(6,56);
print("Original List: ");
//print list
printList();
while(!isEmpty()){
struct node *temp = deleteFirst();
print("nDeleted value:");
print("(%d,%d) ",temp->key,temp->data);
}
print("nList after deleting all items: ");
printList();
insertFirst(1,10);
insertFirst(2,20);
insertFirst(3,30);
insertFirst(4,1);
insertFirst(5,40);
insertFirst(6,56);
print("nRestored List: ");
printList();
print("n");
struct node *foundLink = find(4);
if(foundLink != NULL){
print("Element found: ");
print("(%d,%d) ",foundLink->key,foundLink->data);
print("n");
}else {
print("Element not found.");
}
delete(4);
print("List after deleting an item: ");
printList();
print("n");
foundLink = find(4);
if(foundLink != NULL){
print("Element found: ");
print("(%d,%d) ",foundLink->key,foundLink->data);
print("n");
}else {
print("Element not found.");
}
print("n");
sort();
print("List after sorting the data: ");
printList();
reverse(&head);
print("nList after reversing the data: ");
printList();
}
If we compile and run the above program then it would produce
following result −
Output
Original List:
[ (6,56) (5,40) (4,1) (3,30) (2,20) (1,10) ]
Deleted value:(6,56)
Deleted value:(5,40)
Deleted value:(4,1)
Deleted value:(3,30)
Deleted value:(2,20)
Deleted value:(1,10)
List after deleting all items:
[ ]
Restored List:
[ (6,56) (5,40) (4,1) (3,30) (2,20) (1,10) ]
Element found: (4,1)
List after deleting an item:
[ (6,56) (5,40) (3,30) (2,20) (1,10) ]
Element not found.
List after sorting the data:
[ (1,10) (2,20) (3,30) (5,40) (6,56) ]
List after reversing the data:
[ (6,56) (5,40) (3,30) (2,20) (1,10) ]
Ad

More Related Content

What's hot (20)

Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
Swarup Boro
 
Concatenation of two strings using class in c++
Concatenation of two strings using class in c++Concatenation of two strings using class in c++
Concatenation of two strings using class in c++
Swarup Boro
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03
Nasir Mehmood
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
13. dynamic allocation
13. dynamic allocation13. dynamic allocation
13. dynamic allocation
웅식 전
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
baabtra.com - No. 1 supplier of quality freshers
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
Divya Kumari
 
Java весна 2013 лекция 3
Java весна 2013 лекция 3Java весна 2013 лекция 3
Java весна 2013 лекция 3
Technopark
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory Allocation
Prof Ansari
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
Vikas Sharma
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional credit
Raihan Bin-Mofidul
 
Lab 13
Lab 13Lab 13
Lab 13
Adnan Raza
 
Team 10
Team 10Team 10
Team 10
Sathasivam Rangasamy
 
Function basics
Function basicsFunction basics
Function basics
mohamed sikander
 
Go a crash course
Go   a crash courseGo   a crash course
Go a crash course
Eleanor McHugh
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
Divya Kumari
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
Farhan Ab Rahman
 
week-20x
week-20xweek-20x
week-20x
KITE www.kitecolleges.com
 
C++ TUTORIAL 6
C++ TUTORIAL 6C++ TUTORIAL 6
C++ TUTORIAL 6
Farhan Ab Rahman
 
Kill the DBA
Kill the DBAKill the DBA
Kill the DBA
Knut Haugen
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
Swarup Boro
 
Concatenation of two strings using class in c++
Concatenation of two strings using class in c++Concatenation of two strings using class in c++
Concatenation of two strings using class in c++
Swarup Boro
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03
Nasir Mehmood
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
13. dynamic allocation
13. dynamic allocation13. dynamic allocation
13. dynamic allocation
웅식 전
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
Divya Kumari
 
Java весна 2013 лекция 3
Java весна 2013 лекция 3Java весна 2013 лекция 3
Java весна 2013 лекция 3
Technopark
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory Allocation
Prof Ansari
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional credit
Raihan Bin-Mofidul
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
Divya Kumari
 

Similar to Implement of c &amp; its coding programming by sarmad baloch (20)

Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
teyaj1
 
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdfSolution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
poddaranand1
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf
ankitmobileshop235
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
acarolyn
 
i nsert+in+ link list
i nsert+in+ link listi nsert+in+ link list
i nsert+in+ link list
EAJAJAhamed
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
Chaitanya Kn
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
DaniyalAli81
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
KamalSaini561034
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdf
sooryasalini
 
class 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wd
class 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wdclass 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wd
class 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wd
ankitnegics07
 
class 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbd
class 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbdclass 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbd
class 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbd
ankitnegics07
 
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdfData Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
jyothimuppasani1
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
ritu1806
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structure
ZarghamullahShah
 
Double linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdfDouble linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdf
facevenky
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
Lab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdfLab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdf
21E135MAHIESHWARJ
 
137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
21E135MAHIESHWARJ
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
KUNALHARCHANDANI1
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
teyaj1
 
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdfSolution#includestdio.h#includeconio.h#includealloc.h.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
poddaranand1
 
#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf#includeiostream struct node {    char value;    struct no.pdf
#includeiostream struct node {    char value;    struct no.pdf
ankitmobileshop235
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
acarolyn
 
i nsert+in+ link list
i nsert+in+ link listi nsert+in+ link list
i nsert+in+ link list
EAJAJAhamed
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdf
sooryasalini
 
class 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wd
class 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wdclass 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wd
class 2.pptxdsafe fnbwfl;d,qgyewbjdkqwd;wd
ankitnegics07
 
class 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbd
class 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbdclass 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbd
class 2.pptxdsdhwdhwdbgkjbdqwnddbqsddbbd
ankitnegics07
 
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdfData Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
jyothimuppasani1
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
ritu1806
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structure
ZarghamullahShah
 
Double linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdfDouble linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdf
facevenky
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
JUSTSTYLISH3B2MOHALI
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf#includeiostream#includecstdio#includecstdlibusing names.pdf
#includeiostream#includecstdio#includecstdlibusing names.pdf
KUNALHARCHANDANI1
 
Ad

More from Sarmad Baloch (20)

Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...
Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...
Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...
Sarmad Baloch
 
Positive matrix by sarmad baloch
Positive matrix by sarmad balochPositive matrix by sarmad baloch
Positive matrix by sarmad baloch
Sarmad Baloch
 
Conversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad balochConversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad baloch
Sarmad Baloch
 
Bnak reconciliation statement by sarmad baloch
Bnak reconciliation statement by sarmad balochBnak reconciliation statement by sarmad baloch
Bnak reconciliation statement by sarmad baloch
Sarmad Baloch
 
Introduction of object oriented analysis &amp; design by sarmad baloch
Introduction of object oriented analysis &amp; design by sarmad balochIntroduction of object oriented analysis &amp; design by sarmad baloch
Introduction of object oriented analysis &amp; design by sarmad baloch
Sarmad Baloch
 
Security_saftety_privacy of computer by sarmad baloch
Security_saftety_privacy of computer by sarmad balochSecurity_saftety_privacy of computer by sarmad baloch
Security_saftety_privacy of computer by sarmad baloch
Sarmad Baloch
 
E commerce (introduction to computer) by sarmad baloch
E commerce (introduction to computer) by sarmad balochE commerce (introduction to computer) by sarmad baloch
E commerce (introduction to computer) by sarmad baloch
Sarmad Baloch
 
Programming languages and programme development of computer by sarmad baloch
Programming languages and programme development of computer by sarmad balochProgramming languages and programme development of computer by sarmad baloch
Programming languages and programme development of computer by sarmad baloch
Sarmad Baloch
 
Introduction to computer &amp; its applications by sarmad baloch
Introduction to computer &amp; its applications by sarmad balochIntroduction to computer &amp; its applications by sarmad baloch
Introduction to computer &amp; its applications by sarmad baloch
Sarmad Baloch
 
Accounting principle & concept by sarmad baloch
Accounting principle & concept by sarmad balochAccounting principle & concept by sarmad baloch
Accounting principle & concept by sarmad baloch
Sarmad Baloch
 
The functions of modal auxiliary verbs by sarmad baloch
The functions of modal auxiliary verbs by sarmad balochThe functions of modal auxiliary verbs by sarmad baloch
The functions of modal auxiliary verbs by sarmad baloch
Sarmad Baloch
 
Integrator &amp; diferentiator amplifier presentation by sarmad baloch
Integrator &amp; diferentiator amplifier presentation by sarmad balochIntegrator &amp; diferentiator amplifier presentation by sarmad baloch
Integrator &amp; diferentiator amplifier presentation by sarmad baloch
Sarmad Baloch
 
Ms powerpoint 2007 presentation by sarmad baloch
Ms powerpoint 2007 presentation by sarmad balochMs powerpoint 2007 presentation by sarmad baloch
Ms powerpoint 2007 presentation by sarmad baloch
Sarmad Baloch
 
Semiconductor materials and pn junction by sarmad baloch
Semiconductor materials and pn junction by sarmad balochSemiconductor materials and pn junction by sarmad baloch
Semiconductor materials and pn junction by sarmad baloch
Sarmad Baloch
 
Introduction of BJT,types of Diodes by sarmad baloch
Introduction of BJT,types of Diodes by sarmad balochIntroduction of BJT,types of Diodes by sarmad baloch
Introduction of BJT,types of Diodes by sarmad baloch
Sarmad Baloch
 
Pn junction diode by sarmad baloch
Pn junction diode by sarmad balochPn junction diode by sarmad baloch
Pn junction diode by sarmad baloch
Sarmad Baloch
 
Difference b/w BRITISH vs AMERICAN Language by sarmad khosa
Difference b/w BRITISH vs AMERICAN Language by sarmad khosaDifference b/w BRITISH vs AMERICAN Language by sarmad khosa
Difference b/w BRITISH vs AMERICAN Language by sarmad khosa
Sarmad Baloch
 
ACTIVE & PASSIVE ELECTRONICS by sarmad khosa
ACTIVE & PASSIVE ELECTRONICS by sarmad khosaACTIVE & PASSIVE ELECTRONICS by sarmad khosa
ACTIVE & PASSIVE ELECTRONICS by sarmad khosa
Sarmad Baloch
 
MICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosa
MICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosaMICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosa
MICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosa
Sarmad Baloch
 
Types of DIODES Basic electronics by sarmad khosa
Types of DIODES Basic electronics by sarmad khosaTypes of DIODES Basic electronics by sarmad khosa
Types of DIODES Basic electronics by sarmad khosa
Sarmad Baloch
 
Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...
Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...
Pakistan International cricket stadiums in ADVANCE DATABASE Managment System ...
Sarmad Baloch
 
Positive matrix by sarmad baloch
Positive matrix by sarmad balochPositive matrix by sarmad baloch
Positive matrix by sarmad baloch
Sarmad Baloch
 
Conversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad balochConversion of in fix pre fix,infix by sarmad baloch
Conversion of in fix pre fix,infix by sarmad baloch
Sarmad Baloch
 
Bnak reconciliation statement by sarmad baloch
Bnak reconciliation statement by sarmad balochBnak reconciliation statement by sarmad baloch
Bnak reconciliation statement by sarmad baloch
Sarmad Baloch
 
Introduction of object oriented analysis &amp; design by sarmad baloch
Introduction of object oriented analysis &amp; design by sarmad balochIntroduction of object oriented analysis &amp; design by sarmad baloch
Introduction of object oriented analysis &amp; design by sarmad baloch
Sarmad Baloch
 
Security_saftety_privacy of computer by sarmad baloch
Security_saftety_privacy of computer by sarmad balochSecurity_saftety_privacy of computer by sarmad baloch
Security_saftety_privacy of computer by sarmad baloch
Sarmad Baloch
 
E commerce (introduction to computer) by sarmad baloch
E commerce (introduction to computer) by sarmad balochE commerce (introduction to computer) by sarmad baloch
E commerce (introduction to computer) by sarmad baloch
Sarmad Baloch
 
Programming languages and programme development of computer by sarmad baloch
Programming languages and programme development of computer by sarmad balochProgramming languages and programme development of computer by sarmad baloch
Programming languages and programme development of computer by sarmad baloch
Sarmad Baloch
 
Introduction to computer &amp; its applications by sarmad baloch
Introduction to computer &amp; its applications by sarmad balochIntroduction to computer &amp; its applications by sarmad baloch
Introduction to computer &amp; its applications by sarmad baloch
Sarmad Baloch
 
Accounting principle & concept by sarmad baloch
Accounting principle & concept by sarmad balochAccounting principle & concept by sarmad baloch
Accounting principle & concept by sarmad baloch
Sarmad Baloch
 
The functions of modal auxiliary verbs by sarmad baloch
The functions of modal auxiliary verbs by sarmad balochThe functions of modal auxiliary verbs by sarmad baloch
The functions of modal auxiliary verbs by sarmad baloch
Sarmad Baloch
 
Integrator &amp; diferentiator amplifier presentation by sarmad baloch
Integrator &amp; diferentiator amplifier presentation by sarmad balochIntegrator &amp; diferentiator amplifier presentation by sarmad baloch
Integrator &amp; diferentiator amplifier presentation by sarmad baloch
Sarmad Baloch
 
Ms powerpoint 2007 presentation by sarmad baloch
Ms powerpoint 2007 presentation by sarmad balochMs powerpoint 2007 presentation by sarmad baloch
Ms powerpoint 2007 presentation by sarmad baloch
Sarmad Baloch
 
Semiconductor materials and pn junction by sarmad baloch
Semiconductor materials and pn junction by sarmad balochSemiconductor materials and pn junction by sarmad baloch
Semiconductor materials and pn junction by sarmad baloch
Sarmad Baloch
 
Introduction of BJT,types of Diodes by sarmad baloch
Introduction of BJT,types of Diodes by sarmad balochIntroduction of BJT,types of Diodes by sarmad baloch
Introduction of BJT,types of Diodes by sarmad baloch
Sarmad Baloch
 
Pn junction diode by sarmad baloch
Pn junction diode by sarmad balochPn junction diode by sarmad baloch
Pn junction diode by sarmad baloch
Sarmad Baloch
 
Difference b/w BRITISH vs AMERICAN Language by sarmad khosa
Difference b/w BRITISH vs AMERICAN Language by sarmad khosaDifference b/w BRITISH vs AMERICAN Language by sarmad khosa
Difference b/w BRITISH vs AMERICAN Language by sarmad khosa
Sarmad Baloch
 
ACTIVE & PASSIVE ELECTRONICS by sarmad khosa
ACTIVE & PASSIVE ELECTRONICS by sarmad khosaACTIVE & PASSIVE ELECTRONICS by sarmad khosa
ACTIVE & PASSIVE ELECTRONICS by sarmad khosa
Sarmad Baloch
 
MICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosa
MICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosaMICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosa
MICROSOFT WORD 2007 FULL PRESENTATION BY sarmad khosa
Sarmad Baloch
 
Types of DIODES Basic electronics by sarmad khosa
Types of DIODES Basic electronics by sarmad khosaTypes of DIODES Basic electronics by sarmad khosa
Types of DIODES Basic electronics by sarmad khosa
Sarmad Baloch
 
Ad

Recently uploaded (20)

Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdfRanking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Rafael Villas B
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Lecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptx
Lecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptxLecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptx
Lecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptx
Arshad Shaikh
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Rococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th centuryRococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th century
Gema
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Tax evasion, Tax planning & Tax avoidance.pptx
Tax evasion, Tax  planning &  Tax avoidance.pptxTax evasion, Tax  planning &  Tax avoidance.pptx
Tax evasion, Tax planning & Tax avoidance.pptx
manishbaidya2017
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdfRanking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Rafael Villas B
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Lecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptx
Lecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptxLecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptx
Lecture 2 CLASSIFICATION OF PHYLUM ARTHROPODA UPTO CLASSES & POSITION OF_1.pptx
Arshad Shaikh
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Rococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th centuryRococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th century
Gema
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Tax evasion, Tax planning & Tax avoidance.pptx
Tax evasion, Tax  planning &  Tax avoidance.pptxTax evasion, Tax  planning &  Tax avoidance.pptx
Tax evasion, Tax planning & Tax avoidance.pptx
manishbaidya2017
 

Implement of c &amp; its coding programming by sarmad baloch

  • 1. Implementation in C #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> struct node { Int data; Int key; Struct node *next; }; Struct node *head = NULL; Struct node *current = NULL; //display the list Void print List () { Struct node *par = head; Print ("n [“); //start from the beginning While (par! = NULL) { Print ("(%d, %d) ", par->key, ptr->data); Par = par->next; } Print (“]"); } //insert link at the first location Void insert First (int key, int data) {
  • 2. //create a link Struct node *link = (struct node*) mallow (size of (struct node)); Link->key = key; Link->data = data; //point it to old first node Link->next = head; //point first to new first node Head = link; } //delete first item Struct node* delete First () { //save reference to first link Struct node *Templin = head; //mark next to first link as first Head = head->next; //return the deleted link Return Templin; } //is list empty Bolo is Empty () { Return head == NULL; } int length()
  • 3. { int length = 0; struct node *current; for(current = head; current != NULL; current = current- >next) { length++; } return length; } //find a link with given key struct node* find(int key){ //start from the first link struct node* current = head; //if list is empty if(head == NULL) { return NULL; } //navigate through list while(current->key != key){ //if it is last node if(current->next == NULL){ return NULL; }else { //go to next link current = current->next; }
  • 4. } //if data found, return the current Link return current; } //delete a link with given key struct node* delete(int key){ //start from the first link struct node* current = head; struct node* previous = NULL; //if list is empty if(head == NULL){ return NULL; } //navigate through list while(current->key != key){ //if it is last node if(current->next == NULL){ return NULL; }else { //store reference to current link previous = current; //move to next link current = current->next; } } //found a match, update the link if(current == head) {
  • 5. //change first to point to next link head = head->next; }else { //bypass the current link previous->next = current->next; } return current; } void sort(){ int i, j, k, tempKey, tempData ; struct node *current; struct node *next; int size = length(); k = size ; for ( i = 0 ; i < size - 1 ; i++, k-- ) { current = head ; next = head->next ; for ( j = 1 ; j < k ; j++ ) { if ( current->data > next->data ) { tempData = current->data ; current->data = next->data; next->data = tempData ; tempKey = current->key; current->key = next->key; next->key = tempKey; }
  • 6. current = current->next; next = next->next; } } } void reverse(struct node** head_ref) { struct node* prev = NULL; struct node* current = *head_ref; struct node* next; while (current != NULL) { next = current->next; current->next = prev; prev = current; current = next; } *head_ref = prev; } main() { insertFirst(1,10); insertFirst(2,20); insertFirst(3,30); insertFirst(4,1); insertFirst(5,40); insertFirst(6,56); print("Original List: "); //print list printList();
  • 7. while(!isEmpty()){ struct node *temp = deleteFirst(); print("nDeleted value:"); print("(%d,%d) ",temp->key,temp->data); } print("nList after deleting all items: "); printList(); insertFirst(1,10); insertFirst(2,20); insertFirst(3,30); insertFirst(4,1); insertFirst(5,40); insertFirst(6,56); print("nRestored List: "); printList(); print("n"); struct node *foundLink = find(4); if(foundLink != NULL){ print("Element found: "); print("(%d,%d) ",foundLink->key,foundLink->data); print("n"); }else { print("Element not found."); } delete(4); print("List after deleting an item: "); printList(); print("n"); foundLink = find(4); if(foundLink != NULL){
  • 8. print("Element found: "); print("(%d,%d) ",foundLink->key,foundLink->data); print("n"); }else { print("Element not found."); } print("n"); sort(); print("List after sorting the data: "); printList(); reverse(&head); print("nList after reversing the data: "); printList(); } If we compile and run the above program then it would produce following result − Output Original List: [ (6,56) (5,40) (4,1) (3,30) (2,20) (1,10) ] Deleted value:(6,56) Deleted value:(5,40) Deleted value:(4,1) Deleted value:(3,30) Deleted value:(2,20) Deleted value:(1,10) List after deleting all items: [ ] Restored List: [ (6,56) (5,40) (4,1) (3,30) (2,20) (1,10) ] Element found: (4,1) List after deleting an item: [ (6,56) (5,40) (3,30) (2,20) (1,10) ] Element not found. List after sorting the data: [ (1,10) (2,20) (3,30) (5,40) (6,56) ] List after reversing the data:
  • 9. [ (6,56) (5,40) (3,30) (2,20) (1,10) ]