Write a c program (1.Add record 2.Delete record 3.View record 4.Search record) for bike category.?

Sure! Here's a basic C program that allows you to perform the operations of adding, deleting, viewing, and searching records in the bike category. You can use an array to store the records, and a menu-based system to interact with the user.

```c
#include <stdio.h>
#include <string.h>

struct Bike {
char brand[50];
char model[50];
int year;
};

// Function to add a new record
void addRecord(struct Bike bikes[], int* count) {
printf("Enter brand: ");
scanf("%s", bikes[*count].brand);

printf("Enter model: ");
scanf("%s", bikes[*count].model);

printf("Enter year: ");
scanf("%d", &bikes[*count].year);

(*count)++;
}

// Function to delete a record based on model name
void deleteRecord(struct Bike bikes[], int* count) {
char model[50];

printf("Enter model to delete: ");
scanf("%s", model);

int found = 0;
for (int i = 0; i < *count; i++) {
if (strcmp(bikes[i].model, model) == 0) {
for (int j = i; j < *count - 1; j++) {
strcpy(bikes[j].brand, bikes[j + 1].brand);
strcpy(bikes[j].model, bikes[j + 1].model);
bikes[j].year = bikes[j + 1].year;
}

(*count)--;
found = 1;
break;
}
}

if (found) {
printf("Record deleted successfully!\n");
} else {
printf("Record not found!\n");
}
}

// Function to view all records
void viewRecords(struct Bike bikes[], int count) {
if (count == 0) {
printf("No records found!\n");
return;
}

printf("Bike Records:\n");
for (int i = 0; i < count; i++) {
printf("Brand: %s\n", bikes[i].brand);
printf("Model: %s\n", bikes[i].model);
printf("Year: %d\n\n", bikes[i].year);
}
}

// Function to search for a record based on brand
void searchRecord(struct Bike bikes[], int count) {
char brand[50];

printf("Enter brand to search: ");
scanf("%s", brand);

int found = 0;
for (int i = 0; i < count; i++) {
if (strcmp(bikes[i].brand, brand) == 0) {
printf("Record found:\n");
printf("Brand: %s\n", bikes[i].brand);
printf("Model: %s\n", bikes[i].model);
printf("Year: %d\n\n", bikes[i].year);

found = 1;
}
}

if (!found) {
printf("Record not found!\n");
}
}

int main() {
struct Bike bikes[100]; // Assuming a maximum of 100 records
int count = 0;
int choice;

do {
printf("Menu:\n");
printf("1. Add record\n");
printf("2. Delete record\n");
printf("3. View records\n");
printf("4. Search record\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
addRecord(bikes, &count);
break;
case 2:
deleteRecord(bikes, &count);
break;
case 3:
viewRecords(bikes, count);
break;
case 4:
searchRecord(bikes, count);
break;
case 5:
printf("Exiting program. Bye!");
break;
default:
printf("Invalid choice! Please try again.\n");
}

printf("\n");
} while(choice != 5);

return 0;
}
```

You can compile and run this program to add, delete, view, and search bike records. The program will display a menu with options to perform these operations. Simply enter the corresponding number for the action you want to perform, and follow the prompts to input the required information.