Professional Documents
Culture Documents
Sample Code
Sample Code
h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#define MAX 30
struct bike
{
int cc,cost;
char bikeName[MAX];
struct bike *next;
};
struct bike* insert(struct bike *front, int cuc, char name[], int price)
{
struct bike *newnode;
if (newnode == NULL)
{
printf("\nAllocation failed\n");
exit(2);
}
newnode->cc = cuc;
strcpy(newnode->bikeName, name);
newnode->cost = price;
newnode->next = front;
front = newnode;
return(front);
}
void printNode(struct bike *p)
{
printf("\nBike Details...\n");
printf("\nBike CC : %d", p->cc);
printf("\nName : %s", p->bikeName);
printf("\nPrice On Road : %d\n", p->cost);
printf("-------------------------------------\n");
}
void menu()
{
printf("----------------BIKE DETAILS----------------\n");
printf("Press 1 to insert a bike into the list \n");
printf("Press 2 to delete a bike from the list \n");
printf("Press 3 to display the entire list \n");
printf("Press 4 to search the list \n");
printf("Press 5 to exit \n");
printf("---------------------------------------------\n");
}
int option()
{
int choice;
int main()
{
struct bike *linkList;
char name[21];
char choice;
int cc,price;
linkList = NULL;
case 5: break;
}
} while (choice != 5);
return 0;}