#include"m_list.h"
void main()
{
list *first=NULL,*second=NULL,*third=NULL;
int choice,i;
char ch='y';
while(1)
{
clrscr();
printf("
case 1: Create list");
printf("
case 2: Add in the list");
printf("
case 3: Delete in the list");
printf("
case 4: Append two list");
printf("
case 5: show list");
printf("
case 6: Exit");
printf("
Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1: //create list
while(ch!='n')
{
printf("Enter element : ");
scanf("%d",&i);
create(&first,i);
printf("Enter element (y/n) : ");
fflush(stdin);
scanf("%c",&ch);
}
break;
case 2: //add in the list
int c;
clrscr();
printf("case 1: Add in Beginning");
printf("case 2: Add in End");
printf("case 3: Add After a given element");
printf("case 4: Return to main menu");
printf("Enter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1: add_at_beg(&first);
break;
case 2: add_at_end(&first);
break;
case 3: add_after_given_element(&first);
break;
case 4: break;
}
break;
case 3:
clrscr();
printf("case 1: Delete in Beginning");
printf("case 2: Delete in End");
printf("case 3: Delete a specified element");
printf("case 4: Return to main menu");
printf("Enter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1: del_at_beg(&first);
break;
case 2: del_at_end(&first);
break;
case 3: del_specified_element(&first);
break;
case 4: break;
}
break;
case 4:
char ch='y';
printf("Enter element in second list : ");
while(ch!='n')
{
printf("Enter element : ");
scanf("%d",&i);
create(&second,i);
printf("Enter element (y/n) : ");
fflush(stdin);
scanf("%c",&ch);
}
append(&third,first,second);
break;
case 5: //show list
clrscr();
printf("
case 1: List 1");
printf("
case 2: List 2");
printf("
case 3: List 3");
printf("
Enter choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1: show(first);break;
case 2: show(second);break;
case 3: show(third);break;
}
break;
case 6: exit(0);
}
}
}
*********************************
#include
#include
#include
#include
typedef struct list
{
int info;
struct list *next;
};
//.................Function Declaration ...........
void create(struct list **p,int i)
{
struct list *temp,*q=*p;
temp=(struct list*)malloc(sizeof(struct list));
temp->info=i;
temp->next=NULL;
if(*p==NULL)
*p=temp;
else
{
while(q->next!=NULL)
q=q->next;
q->next=temp;
}
}
int append(struct list **t,struct list *f,struct list *s)
{
struct list *temp=*t;
if(f==NULL && s==NULL)
return 0;
while(f)
{
create(t,f->info);
f=f->next;
}
while(s)
{
create(t,s->info);
s=s->next;
}
return 0;
}
void show(struct list *p)
{
if(p==NULL)
printf(" List is Empty");
else
while(p)
{
printf("%d ",p->info);
p=p->next;
}
getch();
}
void add_at_beg(struct list **l)
{
struct list *temp=(struct list *)malloc(sizeof(struct list));
printf("
Enter element : ");
scanf("%d",&temp->info);
temp->next=NULL;
if(*l==NULL)
*l=temp;
else
{
temp->next=*l;
*l=temp;
}
}
void del_at_beg(struct list **l)
{
list *temp;
if(*l==NULL)
{
printf("
List is empty");
getch();
}
else
{
temp=*l;
*l=(*l)->next;
free(temp);
}
}
void add_at_end(struct list **l)
{
list *temp,*p;
temp=(struct list *)malloc(sizeof(struct list));
printf("
Enter element : ");
scanf("%d",&temp->info);
temp->next=NULL;
if(*l==NULL)
*l=temp;
else
{
p=*l;
while(p->next!=NULL)
p=p->next;
p->next=temp;
}
}
void del_at_end(struct list **l)
{
list *temp,*p;
if(*l==NULL)
{
printf("
List is Empty");
getch();
}
else if((*l)->next==NULL)
{
temp=*l;
*l=NULL;
free(temp);
}
else
{
p=*l;
while(p->next->next!=NULL)
p=p->next;
temp=p->next->next;
p->next=NULL;
free(temp);
}
}
void add_after_given_element(list **l)
{
list *temp,*p;
int m;
temp=(struct list *)malloc(sizeof(struct list));
printf("
Enter element : ");
scanf("%d",&temp->info);
printf("
Enter position after which element inserted : ");
scanf("%d",&m);
temp->next=NULL;
if(*l==NULL)
*l=temp;
else
{
p=*l;
while(p->next!=NULL)
if(p->info==m)
break;
else
p=p->next;
temp->next=p->next;
p->next=temp;
}
}
void del_specified_element(list **l)
{
list *temp,*p,*q;
int m;
printf("
Enter element which is deleted : ");
scanf("%d",&m);
if(*l==NULL)
{
printf("
List is Empty");
getch();
}
else if((*l)->next!=NULL && (*l)->info==m)
{
temp=*l;
*l=(*l)->next;
free(temp);
}
else if((*l)->next==NULL && (*l)->info==m)
{
temp=*l;
*l=NULL;
free(temp);
}
else
{
p=*l;
while(p!=NULL)
if(p->info==m)
break;
else
{
q=p;
p=p->next;
}
temp=p;
q->next=p->next;
free(temp);
}
}
Free C programs with output, C++ (C plus plus), programs c programming language, object oriented programming, c programs codes, c program shortcuts, history of c programming language, c programming compilers
Labels
- 2d example insertion sort
- A bubblesort routine
- A simple example showing some comparison operators
- Add numbers using command line arguments (CLA)
- Add Pointers
- Add two matrices and store the result
- Add Two numbers without using operator
- Addition of Two Matrices
- Addition of two numbers in C++
- Area and Perimeter of Rectangle
- Area and Perimeter of Square
- Area of Circle
- ARRANGE THE ELEMENTS IN ARRAY IN DESSENDING ORDER
- ATM programing
- Basic example showing constants usage in C
- below and average students
- Binary search
- Bubble sort - linked list
- bubble sort -2
- Bubble sort in string array
- C Program find Positive Negative with Switch Case Without Conditional Operator
- C Program to calcuate interest and total amount at the end of each year
- C Programs
- C++ Programs
- Calculate area of two Triangles
- Calculate Average of Four Numbers in C++
- Calculate bill with discount in C++
- Calculate Electric Energy Bill
- Calculate Electricity Bill with if-else condition
- Calculate publishing conference cost
- calculate the power in watts
- Calculate the Sum
- Check Leap Year in C++
- Check Odd or Even Number in C++
- Complex Number
- Concatenate Two Strings
- Construct Pyramid of Numbers
- Convert Decimal to Hexadecimal Number
- Convert Roman Numeral to Decimal
- Copy One File to Another
- Count no. of students above
- count occurrences of values in an array.
- Count the array elements
- Create Linear Linked List
- Decimal to Binary Conversion
- Deleting Element In An Array
- Determine Palindrome String
- dynamic pointer array
- Example of Stack
- Example of Using Strings in C
- Facebook Page
- Factorial Function In C
- Factorial of Number Using While Loop
- Factorial off a number using "do while" loop
- Factorials with Recursive Non Recursive
- Fibonacci Series using Recursive Function
- Find 2's complement of Binary Number
- find a given number is positive or negative number in C without if statement
- Find address of char
- Find Area of Rectangle in C++
- Find Generic root of number
- Find Greater between two numbers in C++
- Find Inverse of a Given Matrix
- Find Maximum Value in Array
- Find Prime Factor of number
- FIND THE SUM OF DIGIT THREE Numbers
- Generate Pascal's Triangle
- Greatest Common Divisor (GCD) - Recursive Non Recursive
- Greatest of two Numbers - Conditional Operator
- Hanoi Problem Recursive and Non Recursive Functions
- heap sort
- History Of C
- how 2 find a given number is positive or negative number in C without using relational and conditional operator
- Hsort
- Implement Trapezoidal Method
- Income Class Example
- INORDER .
- Inserting Elements In An Array
- insertion sort
- Insertion sort in linked list
- integer
- Integer Operands Result
- Isort
- Largest and smallest number Integers
- Length of string and show it in upper
- Linked List implementation
- lower and reverse order
- Mark list Analysis using Structures
- Matrix Multiplication
- Menu Driven Calculator
- Merge sort - linked list
- Merging The Elements In An Array
- Msort Merge sort
- Multiplication of Two Matrices
- Multiply and Division of two numbers
- Multiply and swap 2 nmbers using bitwise operators
- Ohms law example In C
- Print 1 to 10 Series
- Print a double pyramid
- Print all permutations of a given string
- Print Armstrong No.S Less Than 1000
- Print Second Largest Among Given Three No.S
- Progam that gives length of side of a Triangle
- Program for conversion of Decimal to Roman Number
- Program for demonstration of Tree Operations - INSERTION
- Program for finding the transpose of a martix in sparse form
- Program for rotating circles using maths Function
- PROGRAM TO ARRANGE THE ELEMENTS IN ARRAY IN ASSENDING ORDER
- program to calculate sum all of the elments in an array
- Program to compute difference between two dates
- Program to construct a pyramid of any input numbers
- program to find greatest of 2 numbers without using relational and conditional operators
- Program to find whether a number is odd or even
- Program to Open a file
- Pyramid using nested for loops
- Qcksort
- Qserch
- quick sort
- Quick Sort : array of pointers to structures
- read a file and write to a file
- relational and conditional operator
- Reverse First Letter characters
- Reverse Floyds Triangle
- Reverse words in a String C Program
- reversing a linked list
- Search an array
- Search An Element in Linked List
- SEARCHING OF THE ELEMENTS OF BINARY NUMBER
- Searching the Element in an Array
- selection sort in array
- Selection sort linked list
- shell sort array
- Shsort
- Sorting Strings in Ascending Order
- Square Root of a number by using simple calculations
- Ssort
- Standard Deviation using Function
- string
- String array Qsort
- Sub String Given Main String Position
- Substring Replacement
- Subtract
- Subtraction of Two Matrices
- the Swapping of two Values using Functions
- This program calculates an average of the numbers entered
- To delete n Characters from a given position in a given string
- Total Number of Consonants in a String
- Treesort - string array
- Use of Strlen() Function
- Volume of Box in C++
- WAP to add 1 and subtract 1 from value of a and b (Incremental / Decremental Operators)
- WAP to add entered three digits
- WAP to add two variables
- WAP to concatenate two strings
- WAP to Convert CELCIUS to fahrenheit
- WAP to count number of vowels
- WAP to create double dimension array of 2x3 matrix and display its Elements
- WAP to enter character by using getch ( ) function
- WAP to enter records and also repeat the step if user wants to continue
- WAP to find amount of given quantity of any company with 10% discount using switch case
- WAP to find if number=10 then Good else Bad
- WAP to find out Bigger and Equal number from three numbers (Ternary Operators)
- wap to find out bigger number (if-else)
- WAP to find out Bigger number from two numbers (Ternary Operators)
- WAP to find out Even or Odd number (IF-ELSE)
- WAP to find out Positive or Negative (IF-ELSE)
- WAP to find out power of any number
- WAP to find out Quardratic Equation (d=b2-4ac)
- WAP to find out Square root of any number
- WAP to find out Total Bill with discount according to conditions (Ternary Operators)
- WAP to find out total marks and Percentage of three subjects
- WAP to find out total marks of three subjects
- WAP to find out TOTAL SALARY with (IF-ELSE)
- WAP to find out Year is leap or not (IF-ELSE)
- WAP to find size of any variable
- WAP to find string within a string
- WAP to find that number is palandrom or not (121=121)
- WAP to find that number is prime or not
- WAP to find the factorial of the number (1x2x3x4)
- WAP To find the GCD (greatest common divisor) of two given integers
- WAP to find the length of any string
- WAP TO PRINT ANY MESSAGE ON SCREEN
- WAP to print any name on screen 10 times
- WAP to print ASCII code from 0 to 255
- WAP to print Even and Odd numbers from 20 to 1
- WAP to print fabbonic series from 1 to 55
- WAP to print name and display on screen
- WAP to print numbers from 1-50 which are divided by 7
- WAP to print Odd numbers from 1 to 20
- WAP to print series from 1 to 10 and break on 5
- WAP to print series from 1 to 10 and find its square and cube
- WAP to print series from 1 to 10 and skip 5 and 7
- WAP to print series from 20 to 1
- WAP to print series from start to end using do-while loop
- WAP to print Stars on screen
- WAP to print table of 5
- WAP to print the detail of the programmer
- WAP to print value of multiple data types
- WAP to Reverse of any number using while loop
- Wap to reverse words
- WAP to Sum
- WAP to sum of five elements of an array
- WAP to SWAP the three digit number
- Whether the given no. is armstrong or not
- Whether the given no. Is palindrome or not
- Write a C program to find both the largest and smallest number in a list of integers
- write a c program to find prime numbers
- Write a C program to find the sum of individual digits of a positive integer
- Write a C program to generate all the prime numbers between 1 and n
- Write a C program to print all permutations of a given string
- Write a C program to reverse the words in a sentence in place.
- write a program to find the factorial of a number
- write c program to find the roots of a quadratic equation
- Write C program to implement Simpson method
- Write C Program to Print a Triangle
- XOR list example