C ob
C ob
printf("*********************************************************************************
***************************\n");
for (int i = 0; i < studentcount; i++)
{
printf("SN: %d\tID: %d\tName: %s\tGender: %s\tAge: %d\tAddress: %s\tAttendance: %d\n", i + 1,
stud[i].ID, stud[i].name, stud[i].gen, stud[i].Age, stud[i].Add, stud[i].atten);
}
printf("*********************************************************************************
***************************\n");
}
}
// Function to display all teacher or staff records
void display_teach()
{
if (teachercount == 0)
{
printf("\nNo record of teacher/staff was found");
}
else
{
printf("\nThe list of teacher/staff info recorded so far is as follows:\n");
printf("*********************************************************************************
***************************\n");
for (int i = 0; i < teachercount; i++)
{
printf("SN: %d\tID: %d\tName: %s\tRank: %s\tGender: %s\tAge: %d\tAddress: %s\tSalary: %d\n", i + 1,
stud[i].TID, stud[i].Tname, stud[i].rank, stud[i].Tgen, stud[i].TAge, stud[i].TAdd, stud[i].Tsalary);
}
printf("*********************************************************************************
***************************\n");
}
}
int registered_count = 0;
int main() {
char user[20]; // Stores username
int pass, choice, choice2, choice3; // Variables for user choices
top:
// Main menu
printf("-------------------------------------------WELCOME TO ABC LIBRARY MANAGEMENT--------------------
\n");
printf(" Here you can add, search and borrow the needed books!\n");
printf(" Please select what you want to do:\n\n");
printf("->Sign up to our ABC library to gain access, press: 1\n");
printf(" \n Already have an account? \n\n->Login to check your books, press: 2\n");
printf("\nEnter your choice: ");
scanf("%d", &choice);
if (choice == 1) {
// Sign-up process
printf(" Enter the following information
----\n\n");
printf("Enter your username: ");
scanf("%s", user);
printf("\nEnter your password (only numbers): ");
scanf("%d", &pass);
top2:
// Options after signing up or logging in
printf("\n
\n");
printf("\nTo add new books, press: 10\n");
printf("To borrow a book, press: 11\n");
printf("To search for a book by name, press: 12\n");
printf("To search for a book by author, press: 13\n");
printf("To exit, press: 14\n");
printf("To return a book, press: 15\n");
printf("\nWhat would you like to do? ");
printf("\nEnter the choice: ");
scanf("%d", &choice2);
if (choice2 == 10) {
// Adding a new book
if (total_books < 100) {
char new_book[100], new_author[100];
printf("\n Enter the following information
\n\n");
printf("Enter the name of the new book: ");
getchar(); // Clear the input buffer
scanf("%[^\n]%*c", new_book);
printf("Enter the author of the new book: ");
scanf("%[^\n]%*c", new_author);
printf("The book '%s' by %s has been added to the collection!\n", new_book, new_author);
if (choice2 == 12) {
// Search for a book by name
search_books_by_name();
printf("\nTo go back, press: 1\n");
printf("To logout and go to main menu, press: 2\n");
printf("To exit the program, press: 3\n");
scanf("%d", &choice3);
printf("Enter your choice: ");
if (choice3 == 1) {
goto top2;
} else if (choice3 == 2) {
goto top;
} else {
printf("\nExiting the program. Goodbye!");
}
} else if (choice2 == 13) {
// Search for a book by author
search_books_by_author();
printf("\nTo go back, press: 1\n");
printf("To logout and go to main menu, press: 2\n");
printf("To exit the program, press: 3\n");
scanf("%d", &choice3);
printf("Enter your choice: ");
if (choice3 == 1) {
goto top2;
} else if (choice3 == 2) {
goto top;
} else {
printf("\nExiting the program. Goodbye!");
}
} else if (choice2 == 14) {
// Exit the library system
printf("Exiting the library system. Have a great day!\n");
}
else if (choice2 == 15) {
// Return a borrowed book
int book_number;
printf("\nEnter the number of the book you want to return: ");
scanf("%d", &book_number);
else if (choice == 2) {
// Login process
printf("\n Enter the following information
\n\n");
printf("Enter your username: ");
scanf("%s", user);
printf("Enter your password: ");
scanf("%d", &pass);
if (login_user(user, pass)) {
printf("Login successful! Welcome, %s.\n", user);
goto top2;
}
else {
printf("Login failed. Username or password incorrect.\n");
}
}
return 0;
}
Output:
Flow Chart
Block diagram
3. Bus reservation system
#include <stdio.h>
#include <string.h>
#define MAX_USERS 100
#define MAX_BUSES 5
strcpy(registered_users[registered_count].username, user);
registered_users[registered_count].password = pass;
registered_count++;
printf("Registration successful! You can now log in.\n");
goto top;
} else if (choice == 2) { // User login
top:
printf(" Login
\n\n");
printf("Enter your username: ");
scanf("%s", user);
printf("Enter your password: ");
scanf("%d", &pass);
return 0;
}
Output:
Flow Chart
Block diagram
4. Tic Tac Toe
#include <stdio.h>
#define SIZE 3 // Constant for the size of the board
char board[SIZE][SIZE]; // Tic Tac Toe board
char player = 'X'; // Starting player
void viewRecords() {
if (customercount == 0) { // Check if there are no records to display
printf("No records found.\n");
return;
}
printf("\nCustomer Records:\n");
printf("ID\tName\t\tPayment\n");
printf(" \n");
for (int i = 0; i < customercount; i++) {
printf("%d\t%-15s\t%f\n",cust[i].ID, cust[i].name, cust[i].payment);
}
}
void modifyRecord() {
int ID;
printf("Enter customer ID to modify: ");
scanf("%d", &ID);
int found = 0;
int main()
{
int choice;
char c;
printf("--------------------------------------WELCOME TO THE CBA TELECOM BILLING SYSTEM----------
");
top:
printf("\n\nPlease Select what you want to do: \n");
printf("a)For adding new customer record press: 1\n");
printf("b)To view List of records press: 2\n");
printf("c)To Modify Record press: 3\n");
printf("d)To View Payment press: 4\n");
printf("e)To Search Records press: 5\n");
printf("f)To Delete Record press: 6\n");
printf("g)To Exit press: 7\n");
printf("Enter your choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1:
customer_rec();
break;
case 2:
viewRecords();
break;
case 3:
modifyRecord();
break;
case 4:
viewPayment();
break;
case 5:
searchRecord();
break;
case 6:
deleteRecord();
break;
}
printf("\n\nDo you wish continue?(press Y to continue N to exit): ");
scanf("%s",&c);
if(c=='y'||c=='Y')
{
goto top;
}
else
{
printf("Exiting the program.\nExit Successful!");
}
return 0;
}
OUTPUT:
Flow Chart
Block Diagram