You are on page 1of 15

#include<stdio.

h>

#include<stdlib.h>

#include<string.h>

Struct nodeChar dat];

Struct node*next;

Struct node*prev;

};

Char temp[40];

Struct node*head=NULL;

Struct node*current_node=NULL;

Void insert(){

Printf(“Enter Music Name:\n”);

While((getchar())!=’\n’);

Scanf(“%[^\n]%*c”,temp);
Struct node* new_node=(struct node*)malloc(sizeof(struct node));

Strcpy(new_node->data,temp);

If(head==NULL){

New_node->next=new_node->prev=new_node;

Head=current_node=new_node;

Return;

Struct node*last=head->prev;

New_node->prev=last;

Last->next=new_node;

New_node->next=head;

Head->prev=new_node;

}
Void Delete_element(){

If(head==NULL){

Printf(“No Music is there to delete!\n”);

Return;

Printf(“Enter Music Name to delete:\n”);

While((getchar())!=’\n’);

Scanf(“%[^\n]%*c”,temp);

Printf(“\n”);

Struct node*ptr=head;

Do{

If(ptr->next==ptr && strcmp(ptr->data,temp)==0){

Printf(“One file deleted! Playlist is Empty Now!\n”);

Head=NULL;
Free(ptr);

Return;

Else if(strcmp(ptr->data,temp)==0){

Struct node*prev=ptr->prev;

Struct node*next=ptr->next;

Prev->next=next;

Next->prev=prev;

Head=next;

Free(ptr);

Printf(“Music deleted!\n”);

Return;

Ptr=ptr->next;

}while(ptr!=head);
Printf(“No Music file is there!\n”);

Void show(){

If(head==NULL){

Printf(“Playlist is Empty!\n”);

Return;

Struct node*show_ptr=head;

Printf(“\n”);

Int i=1;

Printf(“Displaying Playlist :\n”);

Do{

Printf(“Song %d : %s\n”,I,show_ptr->data);

I++;

Show_ptr=show_ptr->next;
}while(show_ptr!=head);

Void next_node(){

If(current_node==NULL){

Printf(“No songs in Playlist!\n”);

Else{

Current_node=current_node->next;

Printf(“Playing Next Song : %s\n”,current_node->data);

Void prev_node(){
If(current_node==NULL){

Printf(“No songs in Playlist!\n”);

Else{

Current_node=current_node->prev;

Printf(“Playing Previous Song : %s\n”,current_node->data);

Void first_node(){

If(head==NULL){

Printf(“Playlist is Empty!\n”);

Else{

Printf(“Playing First Music : %s\n”,head->data);


}

Void last_node(){

If(head==NULL){

Printf(“Playlist is Empty!\n”);

Else{

Printf(“Playing Last Music : %s\n”,head->prev->data);

Void specific_data(){

If(head==NULL){

Printf(“No music is there to be searched!\n”);

Return;
}

Printf(“Enter Music Name to delete:\n”);

While((getchar())!=’\n’);

Scanf(“%[^\n]%*c”,temp);

Printf(“\n”);

Struct node*ptr=head;

Do{

If(strcmp(ptr->data,temp)==0){

Printf(“Music Found!\n”);

Printf(“Playing Music : %s\n”,ptr->data);

Return;

Ptr=ptr->next;

}while(ptr!=head);
Printf(“There is no Music file with this name!\n”);

Int main(){

Int choice;

Menu:

Printf(“\n-----Song Playlist Application-----\n”);

Printf(“1. Add Music\n”);

Printf(“2. Remove Music\n”);

Printf(“3. Show Playlist\n”);

Printf(“4. Play next file\n”);

Printf(“5. Play previous file,\n”);

Printf(“6. Play first file\n”);

Printf(“7. Play Last file\n”);

Printf(“8. Play specific file.\n”);


Printf(“9. Exit\n\n”);

Scanf(“%d”,&choice);

If (choice == 1)

Insert();

Else if (choice == 2)

Delete_element();

Else if (choice == 3)

Show();

Else if (choice == 4)

Next_node();
Else if (choice == 5)

Prev_node();

Else if (choice == 6)

First_node();

Else if (choice == 7)

Last_node();

Else if (choice == 8)

Specific_data();

Else

Exit(0);
Goto menu;

Return 0;

OUTPUT :

-----Song Playlist Application-----

1. Add Music

2. Remove Music

3. Show Playlist

4. Play next file

5. Play previous file,

6. Play first file

7. Play Last file

8. Play specific file.


9. Exit

Playlist is Empty!

-----Song Playlist Application-----

1. Add Music

2. Remove Music

3. Show Playlist

4. Play next file

5. Play previous file,

6. Play first file

7. Play Last file


8. Play specific file.

9. Exit

You might also like