SHOWING THE SECOND LAST ELEMENT OF A LINKED LISTS
Language=C
#include<stdio.h>
#include<stdlib.h>
struct linked_lists
{
int data;
struct linked_lists *next;
};
typedef struct linked_lists node;
void create( node *list );
void show_before_last( node *list );
int main()
{
node *head;
head = ( node* ) malloc( sizeof( node ) );
create( head );
show_before_last( head );
return 0;
}
void create( node *list )
{
char c;
scanf( "%d%c",&list->data,&c );
if(c == '\n')
list->next = NULL;
else
{
list->next = ( node* ) malloc ( sizeof( node ) );
create( list->next );
}
return;
}
void show_before_last( node *list )
{
while( list->next->next )
list = list->next;
printf( "%d\n",list->data );
return;
}
Sunday, 14 August 2016
Subscribe to:
Post Comments (Atom)
Kruskal Algorithm
Minimum Cost Spanning Tree By Kruskal Algorithm using priority_queue in c++ #include<bits/stdc++.h> using namespace std; typedef p...
-
Introduction: What is Computer Programming?This is the burning question for all who are interested in ...
-
SWAPPING TO NUMBERS WITHOUT TAKING ANY TEMPORARY VARIABLE /*We generally swap or interchange to variables by taking a temporary variabl...
-
Java:Sorting an array //This program will take some random values and sort them in ascending order import static java.lang.Math.abs; i...
No comments:
Post a Comment