Sunday, March 30, 2025

C program that simulates a token system for visiting a temple updated version of the program with additional features and functionality

 C program that simulates a token system for visiting a temple updated version of the program with additional features and functionality


Here's an updated version of the program with additional features and functionality:


Temple Token System


#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#include <string.h>


// Define structure for tokens

typedef struct {

    int tokenNumber;

    time_t dateTime;

    char visitorName[50];

    char visitorContact[50];

} Token;


// Define structure for temple management

typedef struct {

    int maxTokens;

    int tokenCount;

    Token tokens[100];

} TempleManagement;


// Function to create a new token

Token createToken(int tokenNumber, char *visitorName, char *visitorContact) {

    Token token;

    token.tokenNumber = tokenNumber;

    token.dateTime = time(NULL);

    strcpy(token.visitorName, visitorName);

    strcpy(token.visitorContact, visitorContact);

    return token;

}


// Function to display token details

void displayToken(Token token) {

    printf("Token Number: %d\n", token.tokenNumber);

    printf("Date and Time: %s", ctime(&token.dateTime));

    printf("Visitor Name: %s\n", token.visitorName);

    printf("Visitor Contact: %s\n", token.visitorContact);

}


// Function to generate tokens

void generateTokens(TempleManagement *templeManagement, char *visitorName, char *visitorContact) {

    if (templeManagement->tokenCount < templeManagement->maxTokens) {

        Token token = createToken(templeManagement->tokenCount + 1, visitorName, visitorContact);

        templeManagement->tokens[templeManagement->tokenCount] = token;

        templeManagement->tokenCount++;

        printf("\nToken generated successfully!\n");

        displayToken(token);

    } else {

        printf("\nSorry, maximum tokens reached!\n");

    }

}


// Function to cancel tokens

void cancelTokens(TempleManagement *templeManagement, int tokenNumber) {

    for (int i = 0; i < templeManagement->tokenCount; i++) {

        if (templeManagement->tokens[i].tokenNumber == tokenNumber) {

            templeManagement->tokenCount--;

            for (int j = i; j < templeManagement->tokenCount; j++) {

                templeManagement->tokens[j] = templeManagement->tokens[j + 1];

            }

            printf("\nToken cancelled successfully!\n");

            return;

        }

    }

    printf("\nSorry, token not found!\n");

}


// Function to display temple management details

void displayTempleManagement(TempleManagement templeManagement) {

    printf("\nTemple Management Details:\n");

    printf("Maximum Tokens: %d\n", templeManagement.maxTokens);

    printf("Token Count: %d\n", templeManagement.tokenCount);

    printf("\nTokens:\n");

    for (int i = 0; i < templeManagement.tokenCount; i++) {

        printf("\nToken %d:\n", templeManagement.tokens[i].tokenNumber);

        displayToken(templeManagement.tokens[i]);

    }

}


int main() {

    TempleManagement templeManagement;

    templeManagement.maxTokens = 100;

    templeManagement.tokenCount = 0;


    while (1) {

        printf("\nTemple Token System\n");

        printf("1. Generate Token\n");

        printf("2. Cancel Token\n");

        printf("3. Display Temple Management Details\n");

        printf("4. Exit\n");

        printf("Enter your choice: ");

        int choice;

        scanf("%d", &choice);


        switch (choice) {

            case 1: {

                char visitorName[50];

                char visitorContact[50];

                printf("Enter visitor name: ");

                scanf("%s", visitorName);

                printf("Enter visitor contact: ");

                scanf("%s", visitorContact);

                generateTokens(&templeManagement, visitorName, visitorContact);

                break;

            }

            case 2: {

                int tokenNumber;

                printf("Enter token number to cancel: ");

                scanf("%d", &tokenNumber);

                cancelTokens(&templeManagement, tokenNumber);

                break;

            }

            case 3:

                displayTempleManagement(templeManagement);

                break;

            case 4:

                printf("Exiting...\n");

                return 0;

            default:

                printf("Invalid choice! Please choose again.\n");

        }

    }


    return 0;

}



This updated program includes the following additional features:

1. Temple management structure: 

A structure to represent temple management details, including maximum tokens and token count.

2. Token cancellation:

 A function to cancel tokens based on token number.

3. Temple management details display: 

A function to display temple management details, including maximum tokens, token count, and tokens.

4. Menu-driven interface: 

A menu-driven interface to interact with the program and perform various operations.


Note that this program is still a simplified example and does not cover real-world complexities like:


- User authentication and authorization

- Token validation and verification

- Integration with temple management systems

- Handling of special cases, such as token cancellations or rescheduling


To make this program more robust and realistic, you would need to consider these factors and add additional features and functionality.


Some possible future enhancements:


1. User authentication: 

Add user authentication to ensure only authorized personnel can generate or cancel tokens.

2. Token validation: 

Implement token validation to prevent fraudulent or duplicate tokens.

3. Integration with temple management systems:

Integrate the token system with existing temple management systems for seamless operation.

4. Handling special cases:

 Develop strategies to handle special cases, such as token cancellations or rescheduling, to ensure smooth operation.

5. Scalability and performance:

 Optimize the program for scalability and performance to handle a large volume of tokens and users.


By addressing these aspects and adding more features, you can create a comprehensive and efficient token system for the temple.

C program that simulates a token system for visiting a temple:

 Here's a simplified C program that simulates a token system for visiting a temple:


Temple Token System


#include <stdio.h>

#include <stdlib.h>

#include <time.h>


// Define structure for tokens

typedef struct {

    int tokenNumber;

    time_t dateTime;

} Token;


// Function to create a new token

Token createToken(int tokenNumber) {

    Token token;

    token.tokenNumber = tokenNumber;

    token.dateTime = time(NULL);

    return token;

}


// Function to display token details

void displayToken(Token token) {

    printf("Token Number: %d\n", token.tokenNumber);

    printf("Date and Time: %s", ctime(&token.dateTime));

}


// Function to generate tokens

void generateTokens(int tokenCount) {

    Token tokens[tokenCount];

    for (int i = 0; i < tokenCount; i++) {

        tokens[i] = createToken(i + 1);

        printf("\nToken %d:\n", i + 1);

        displayToken(tokens[i]);

    }

}


int main() {

    int tokenCount;

    printf("Enter the number of tokens to generate: ");

    scanf("%d", &tokenCount);

    generateTokens(tokenCount);

    return 0;

}



This program demonstrates the following concepts:


1. *Token structure*: A structure to represent tokens with attributes like token number and date/time.

2. *Token creation*: A function to create new tokens with a unique token number and current date/time.

3. *Token display*: A function to display token details, including token number and date/time.

4. *Token generation*: A function to generate multiple tokens based on user input.


Note that this program is a highly simplified example and does not cover real-world complexities like:


- User authentication and authorization

- Token validation and verification

- Integration with temple management systems

- Handling of special cases, such as token cancellations or rescheduling


To make this program more robust and realistic, you would need to consider these factors and add additional features and functionality.

C program that simulates a basic indoor game, "Treasure Hunt".

 Here's a simplified C program that simulates a basic indoor game, "Treasure Hunt".


Treasure Hunt Game


#include <stdio.h>

#include <stdlib.h>

#include <time.h>


// Define structure for rooms

typedef struct {

    char name[50];

    char description[100];

    int treasure;

} Room;


// Define structure for players

typedef struct {

    char name[50];

    int score;

} Player;


// Function to create a new room

Room createRoom(char *name, char *description, int treasure) {

    Room room;

    strcpy(room.name, name);

    strcpy(room.description, description);

    room.treasure = treasure;

    return room;

}


// Function to create a new player

Player createPlayer(char *name) {

    Player player;

    strcpy(player.name, name);

    player.score = 0;

    return player;

}


// Function to play the game

void playGame(Room *rooms, int roomCount, Player *player) {

    int currentRoom = 0;

    while (1) {

        printf("\nYou are in the %s.\n", rooms[currentRoom].name);

        printf("%s\n", rooms[currentRoom].description);

        printf("Do you want to:\n1. Move to the next room\n2. Search for treasure\n3. Quit the game\n");

        int choice;

        scanf("%d", &choice);

        switch (choice) {

            case 1:

                if (currentRoom < roomCount - 1) {

                    currentRoom++;

                } else {

                    printf("You are already in the last room!\n");

                }

                break;

            case 2:

                if (rooms[currentRoom].treasure) {

                    printf("You found treasure! Your score increases by 10 points.\n");

                    player->score += 10;

                } else {

                    printf("There is no treasure in this room!\n");

                }

                break;

            case 3:

                printf("Thanks for playing! Your final score is %d.\n", player->score);

                return;

            default:

                printf("Invalid choice! Please choose again.\n");

        }

    }

}


int main() {

    // Create rooms

    Room room1 = createRoom("Room 1", "This is the first room.", 1);

    Room room2 = createRoom("Room 2", "This is the second room.", 0);

    Room room3 = createRoom("Room 3", "This is the third room.", 1);

    Room rooms[] = {room1, room2, room3};

    int roomCount = sizeof(rooms) / sizeof(rooms[0]);


    // Create player

    char playerName[50];

    printf("Enter your name: ");

    scanf("%s", playerName);

    Player player = createPlayer(playerName);


    // Play the game

    playGame(rooms, roomCount, &player);


    return 0;

}



This program demonstrates the following concepts:


1. *Room structure*: A structure to represent rooms with attributes like name, description, and treasure.

2. *Player structure*: A structure to represent players with attributes like name and score.

3. *Gameplay*: A function to simulate the gameplay, where the player navigates through rooms, searches for treasure, and earns points.


Note that this program is a highly simplified example and does not cover real-world complexities like game design, user input handling, and scoring systems.

C program that simulates a kirana store's billing system

 Here's a simplified C program that simulates a kirana store's billing system:


Kirana Store Billing Program


#include <stdio.h>

#include <stdlib.h>


// Define structure for products

typedef struct {

    char name[50];

    float retailRate;

    float wholesaleRate;

    int quantity;

} Product;


// Define structure for bills

typedef struct {

    Product product;

    float rate;

    int quantity;

    float amount;

} Bill;


// Function to create a new product

Product createProduct(char *name, float retailRate, float wholesaleRate, int quantity) {

    Product product;

    strcpy(product.name, name);

    product.retailRate = retailRate;

    product.wholesaleRate = wholesaleRate;

    product.quantity = quantity;

    return product;

}


// Function to create a new bill

Bill createBill(Product product, float rate, int quantity) {

    Bill bill;

    bill.product = product;

    bill.rate = rate;

    bill.quantity = quantity;

    bill.amount = rate * quantity;

    return bill;

}


// Function to display bill details

void displayBill(Bill bill) {

    printf("Product Name: %s\n", bill.product.name);

    printf("Rate: %.2f\n", bill.rate);

    printf("Quantity: %d\n", bill.quantity);

    printf("Amount: %.2f\n", bill.amount);

}


// Function to calculate total profit

float calculateProfit(Bill *bills, int billCount) {

    float totalProfit = 0;

    for (int i = 0; i < billCount; i++) {

        if (bills[i].rate == bills[i].product.wholesaleRate) {

            totalProfit += (bills[i].product.retailRate - bills[i].product.wholesaleRate) * bills[i].quantity;

        }

    }

    return totalProfit;

}


int main() {

    // Create products

    Product product1 = createProduct("Rice", 50.0, 40.0, 100);

    Product product2 = createProduct("Wheat", 30.0, 25.0, 50);


    // Create bills

    Bill bill1 = createBill(product1, 50.0, 20);

    Bill bill2 = createBill(product2, 25.0, 30);

    Bill bill3 = createBill(product1, 40.0, 50); // Wholesale rate


    // Display bill details

    printf("Bill 1:\n");

    displayBill(bill1);

    printf("\nBill 2:\n");

    displayBill(bill2);

    printf("\nBill 3:\n");

    displayBill(bill3);


    // Calculate total profit

    Bill bills[] = {bill1, bill2, bill3};

    float totalProfit = calculateProfit(bills, 3);

    printf("\nTotal Profit: %.2f\n", totalProfit);


    return 0;

}



This program demonstrates the following concepts:


1. *Product structure*: A structure to represent products with attributes like name, retail rate, wholesale rate, and quantity.

2. *Bill structure*: A structure to represent bills with attributes like product, rate, quantity, and amount.

3. *Billing system*: A system to create bills based on product rates and quantities.

4. *Profit calculation*: A function to calculate the total profit earned by selling products at retail and wholesale rates.


Note that this program is a highly simplified example and does not cover real-world complexities like inventory management, customer management, and tax calculations.

Saturday, March 29, 2025

C program to deliver the product at the address

 Here's a simplified C program that simulates delivering a product to an address:


Product Delivery Program


#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <time.h>


// Define structure for products

typedef struct {

    int id;

    char name[50];

    float price;

} Product;


// Define structure for addresses

typedef struct {

    char street[100];

    char city[50];

    char state[50];

    int zip;

} Address;


// Define structure for deliveries

typedef struct {

    Product product;

    Address address;

    time_t deliveryTime;

} Delivery;


// Function to create a new product

Product createProduct(int id, char *name, float price) {

    Product product;

    product.id = id;

    strcpy(product.name, name);

    product.price = price;

    return product;

}


// Function to create a new address

Address createAddress(char *street, char *city, char *state, int zip) {

    Address address;

    strcpy(address.street, street);

    strcpy(address.city, city);

    strcpy(address.state, state);

    address.zip = zip;

    return address;

}


// Function to create a new delivery

Delivery createDelivery(Product product, Address address) {

    Delivery delivery;

    delivery.product = product;

    delivery.address = address;

    delivery.deliveryTime = time(NULL);

    return delivery;

}


// Function to display delivery details

void displayDelivery(Delivery delivery) {

    printf("Product ID: %d\n", delivery.product.id);

    printf("Product Name: %s\n", delivery.product.name);

    printf("Product Price: %.2f\n", delivery.product.price);

    printf("Delivery Address: %s, %s, %s %d\n", delivery.address.street, delivery.address.city, delivery.address.state, delivery.address.zip);

    printf("Delivery Time: %s", ctime(&delivery.deliveryTime));

}


int main() {

    // Create products

    Product product1 = createProduct(1, "Laptop", 999.99);

    Product product2 = createProduct(2, "Smartphone", 799.99);


    // Create addresses

    Address address1 = createAddress("123 Main St", "Anytown", "CA", 12345);

    Address address2 = createAddress("456 Elm St", "Othertown", "NY", 67890);


    // Create deliveries

    Delivery delivery1 = createDelivery(product1, address1);

    Delivery delivery2 = createDelivery(product2, address2);


    // Display delivery details

    printf("Delivery 1:\n");

    displayDelivery(delivery1);

    printf("\nDelivery 2:\n");

    displayDelivery(delivery2);


    return 0;

}


This program demonstrates the following concepts:


1. *Product structure*: A structure to represent products with attributes like ID, name, and price.

2. *Address structure*: A structure to represent addresses with attributes like street, city, state, and zip.

3. *Delivery structure*: A structure to represent deliveries with attributes like product, address, and delivery time.

4. *Delivery creation*: Functions to create products, addresses, and deliveries.

5. *Delivery display*: A function to display delivery details.


Note that this program is a highly simplified example and does not cover real-world complexities like logistics, payment processing, and order management.

C program to make a cryptocurrency

 Creating a cryptocurrency is a complex task that requires a deep understanding of cryptography, networking, and economics. Here's a simplified C program that demonstrates some basic concepts:


Cryptocurrency Program


#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <time.h>


// Define structure for blocks

typedef struct Block {

    int index;

    time_t timestamp;

    char previousHash[64];

    char hash[64];

    char data[256];

} Block;


// Define structure for transactions

typedef struct Transaction {

    char sender[50];

    char receiver[50];

    float amount;

} Transaction;


// Define structure for blockchain

typedef struct Blockchain {

    Block *blocks;

    int blockCount;

} Blockchain;


// Function to create a new block

Block createBlock(int index, time_t timestamp, char *previousHash, char *data) {

    Block block;

    block.index = index;

    block.timestamp = timestamp;

    strcpy(block.previousHash, previousHash);

    strcpy(block.data, data);

    // Calculate hash using SHA-256

    // For simplicity, this example uses a fake hash function

    sprintf(block.hash, "Hash%d", index);

    return block;

}


// Function to add a new block to the blockchain

void addBlock(Blockchain *blockchain, Block block) {

    blockchain->blocks = realloc(blockchain->blocks, (blockchain->blockCount + 1) * sizeof(Block));

    blockchain->blocks[blockchain->blockCount] = block;

    blockchain->blockCount++;

}


// Function to create a new transaction

Transaction createTransaction(char *sender, char *receiver, float amount) {

    Transaction transaction;

    strcpy(transaction.sender, sender);

    strcpy(transaction.receiver, receiver);

    transaction.amount = amount;

    return transaction;

}


// Function to add a new transaction to the blockchain

void addTransaction(Blockchain *blockchain, Transaction transaction) {

    // For simplicity, this example assumes transactions are stored in the block data

    char data[256];

    sprintf(data, "Transaction from %s to %s for %.2f", transaction.sender, transaction.receiver, transaction.amount);

    Block block = createBlock(blockchain->blockCount, time(NULL), blockchain->blocks[blockchain->blockCount - 1].hash, data);

    addBlock(blockchain, block);

}


int main() {

    Blockchain blockchain;

    blockchain.blocks = malloc(sizeof(Block));

    blockchain.blockCount = 0;


    // Create genesis block

    Block genesisBlock = createBlock(0, time(NULL), "Genesis", "Genesis Block");

    addBlock(&blockchain, genesisBlock);


    // Create transactions

    Transaction transaction1 = createTransaction("Alice", "Bob", 10.0);

    Transaction transaction2 = createTransaction("Bob", "Charlie", 5.0);


    // Add transactions to the blockchain

    addTransaction(&blockchain, transaction1);

    addTransaction(&blockchain, transaction2);


    // Print blockchain

    for (int i = 0; i < blockchain.blockCount; i++) {

        printf("Block %d:\n", blockchain.blocks[i].index);

        printf("Timestamp: %ld\n", blockchain.blocks[i].timestamp);

        printf("Previous Hash: %s\n", blockchain.blocks[i].previousHash);

        printf("Hash: %s\n", blockchain.blocks[i].hash);

        printf("Data: %s\n\n", blockchain.blocks[i].data);

    }


    return 0;

}


This program demonstrates the following concepts:


1. *Blockchain*: A chain of blocks, each containing a timestamp, previous hash, hash, and data.

2. *Blocks*: Individual units of the blockchain, containing a unique index, timestamp, previous hash, hash, and data.

3. *Transactions*: Data stored in the blocks, representing a transfer of value between parties.

4. *Hash function*: A function that takes input data and produces a fixed-size string of characters, used to identify blocks and transactions.


Note that this program is a highly simplified example and is not suitable for creating a real-world cryptocurrency. A real cryptocurrency would require a much more complex implementation, including:


- A secure hash function, such as SHA-256

- A consensus algorithm, such as proof-of-work or proof-of-stake

- A network of nodes to validate and relay transactions

- A wallet system for users to store and manage their cryptocurrency

- A user-friendly interface for interacting with the cryptocurrency

Simple C program to manage shopping malls inventory and sales

 Here's a simplified C program to manage a shopping mall's inventory and sales:


Shopping Mall Management System




#include <stdio.h>

#include <stdlib.h>

#include <string.h>


// Define structure for products

typedef struct {

    int id;

    char name[50];

    float price;

    int quantity;

} Product;


// Function to add products

void addProduct(Product *products, int *productCount) {

    printf("Enter product ID: ");

    scanf("%d", &products[*productCount].id);

    printf("Enter product name: ");

    scanf("%s", products[*productCount].name);

    printf("Enter product price: ");

    scanf("%f", &products[*productCount].price);

    printf("Enter product quantity: ");

    scanf("%d", &products[*productCount].quantity);

    (*productCount)++;

}


// Function to display products

void displayProducts(Product *products, int productCount) {

    printf("Product List:\n");

    for (int i = 0; i < productCount; i++) {

        printf("ID: %d, Name: %s, Price: %.2f, Quantity: %d\n",

               products[i].id, products[i].name, products[i].price, products[i].quantity);

    }

}


// Function to sell products

void sellProduct(Product *products, int productCount) {

    int productId;

    printf("Enter product ID to sell: ");

    scanf("%d", &productId);

    for (int i = 0; i < productCount; i++) {

        if (products[i].id == productId) {

            if (products[i].quantity > 0) {

                products[i].quantity--;

                printf("Product sold successfully!\n");

            } else {

                printf("Product out of stock!\n");

            }

            return;

        }

    }

    printf("Product not found!\n");

}


int main() {

    Product products[100];

    int productCount = 0;

    int choice;


    while (1) {

        printf("Shopping Mall Management System\n");

        printf("1. Add Product\n");

        printf("2. Display Products\n");

        printf("3. Sell Product\n");

        printf("4. Exit\n");

        printf("Enter your choice: ");

        scanf("%d", &choice);


        switch (choice) {

            case 1:

                addProduct(products, &productCount);

                break;

            case 2:

                displayProducts(products, productCount);

                break;

            case 3:

                sellProduct(products, productCount);

                break;

            case 4:

                exit(0);

            default:

                printf("Invalid choice!\n");

        }

    }


    return 0;

}



This program allows users to:


1. Add products to the inventory

2. Display the list of products

3. Sell products (reduce quantity)


Note that this is a simplified program and doesn't include features like user authentication, data validation, or file persistence.

Advanced C program for shopping mall management system

 Here's an updated version of the C program with additional features:


Shopping Mall Management System




#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <time.h>


// Define structure for products

typedef struct {

    int id;

    char name[50];

    float price;

    int quantity;

} Product;


// Define structure for users

typedef struct {

    char username[50];

    char password[50];

} User;


// Function to add products

void addProduct(Product *products, int *productCount) {

    printf("Enter product ID: ");

    scanf("%d", &products[*productCount].id);

    printf("Enter product name: ");

    scanf("%s", products[*productCount].name);

    printf("Enter product price: ");

    scanf("%f", &products[*productCount].price);

    printf("Enter product quantity: ");

    scanf("%d", &products[*productCount].quantity);

    (*productCount)++;

}


// Function to display products

void displayProducts(Product *products, int productCount) {

    printf("Product List:\n");

    for (int i = 0; i < productCount; i++) {

        printf("ID: %d, Name: %s, Price: %.2f, Quantity: %d\n",

               products[i].id, products[i].name, products[i].price, products[i].quantity);

    }

}


// Function to sell products

void sellProduct(Product *products, int productCount) {

    int productId;

    printf("Enter product ID to sell: ");

    scanf("%d", &productId);

    for (int i = 0; i < productCount; i++) {

        if (products[i].id == productId) {

            if (products[i].quantity > 0) {

                products[i].quantity--;

                printf("Product sold successfully!\n");

            } else {

                printf("Product out of stock!\n");

            }

            return;

        }

    }

    printf("Product not found!\n");

}


// Function to authenticate users

int authenticateUser(User *users, int userCount, char *username, char *password) {

    for (int i = 0; i < userCount; i++) {

        if (strcmp(users[i].username, username) == 0 && strcmp(users[i].password, password) == 0) {

            return 1;

        }

    }

    return 0;

}


// Function to add users

void addUser(User *users, int *userCount) {

    printf("Enter username: ");

    scanf("%s", users[*userCount].username);

    printf("Enter password: ");

    scanf("%s", users[*userCount].password);

    (*userCount)++;

}


// Function to display users

void displayUsers(User *users, int userCount) {

    printf("User List:\n");

    for (int i = 0; i < userCount; i++) {

        printf("Username: %s\n", users[i].username);

    }

}


// Function to save data to file

void saveData(Product *products, int productCount, User *users, int userCount) {

    FILE *fp;

    fp = fopen("data.txt", "w");

    if (fp == NULL) {

        printf("Error opening file!\n");

        return;

    }

    for (int i = 0; i < productCount; i++) {

        fprintf(fp, "%d,%s,%.2f,%d\n", products[i].id, products[i].name, products[i].price, products[i].quantity);

    }

    for (int i = 0; i < userCount; i++) {

        fprintf(fp, "%s,%s\n", users[i].username, users[i].password);

    }

    fclose(fp);

}


// Function to load data from file

void loadData(Product *products, int *productCount, User *users, int *userCount) {

    FILE *fp;

    fp = fopen("data.txt", "r");

    if (fp == NULL) {

        printf("Error opening file!\n");

        return;

    }

    char line[100];

    while (fgets(line, sizeof(line), fp)) {

        char *token = strtok(line, ",");

        if (token != NULL) {

            products[*productCount].id = atoi(token);

            token = strtok(NULL, ",");

            strcpy(products[*productCount].name, token);

            token = strtok(NULL, ",");

            products[*productCount].price = atof(token);

            token = strtok(NULL, "\n");

            products[*productCount].quantity = atoi(token);

            (*productCount)++;

        } else {

            token = strtok(line, ",");

            strcpy(users[*userCount].username, token);

            token = strtok(NULL, "\n");

            strcpy(users[*userCount].password, token);

            (*userCount)++;

        }

    }

    fclose

    fclose(fp);

}


int main() {

    Product products[100];

    int productCount = 0;

    User users[100];

    int userCount = 0;

    int choice;

    char username[50];

    char password[50];


    // Load data from file

    loadData(products, &productCount, users, &userCount);


    while (1) {

        printf("Shopping Mall Management System\n");

        printf("1. Login\n");

        printf("2. Register\n");

        printf("3. Exit\n");

        printf("Enter your choice: ");

        scanf("%d", &choice);


        switch (choice) {

            case 1:

                printf("Enter username: ");

                scanf("%s", username);

                printf("Enter password: ");

                scanf("%s", password);

                if (authenticateUser(users, userCount, username, password)) {

                    printf("Login successful!\n");

                    while (1) {

                        printf("1. Add Product\n");

                        printf("2. Display Products\n");

                        printf("3. Sell Product\n");

                        printf("4. Display Users\n");

                        printf("5. Logout\n");

                        printf("Enter your choice: ");

                        scanf("%d", &choice);


                        switch (choice) {

                            case 1:

                                addProduct(products, &productCount);

                                break;

                            case 2:

                                displayProducts(products, productCount);

                                break;

                            case 3:

                                sellProduct(products, productCount);

                                break;

                            case 4:

                                displayUsers(users, userCount);

                                break;

                            case 5:

                                printf("Logout successful!\n");

                                break;

                            default:

                                printf("Invalid choice!\n");

                        }

                    }

                } else {

                    printf("Invalid username or password!\n");

                }

                break;

            case 2:

                addUser(users, &userCount);

                printf("Registration successful!\n");

                break;

            case 3:

                printf("Exiting...\n");

                saveData(products, productCount, users, userCount);

                exit(0);

            default:

                printf("Invalid choice!\n");

        }

    }


    return 0;

}



This program includes the following features:


1. *User authentication*: Users can log in with their username and password.

2. *User registration*: New users can register by providing a username and password.

3. *Product management*: Users can add, display, and sell products.

4. *User management*: Users can display the list of registered users.

5. *Data persistence*: Program data is saved to a file when the program exits.


Note that this program uses a simple text-based file for data storage, which is not secure for storing sensitive information like passwords. In a real-world application, you would want to use a more secure method of storing user credentials.

Thursday, March 27, 2025

Shaheed Bhagat Singh

 Shaheed Bhagat Singh 



Shaheed Bhagat Singh was a renowned Indian revolutionary and freedom fighter who played a pivotal role in the Indian independence movement.



 Here's a brief overview of his life and legacy:


Early Life and Education

Bhagat Singh was born on September 28, 1907, in Lyallpur, Punjab (now in Pakistan), to Kishan Singh and Vidyavati. He came from a family of freedom fighters and was deeply influenced by his father's revolutionary activities.


Revolutionary Activities

Bhagat Singh joined the Hindustan Republican Association (HRA) and became a key figure in the Indian independence movement. He advocated for the use of armed revolution to overthrow British rule and was involved in several notable incidents, including:


1. *The Lahore Conspiracy Case*: Bhagat Singh and his comrades threw bombs in the Central Legislative Assembly in Delhi, protesting the Public Safety Bill and the Trade Disputes Bill.

2. *The murder of John P. Saunders*: Bhagat Singh and his associates killed a British police officer, John P. Saunders, in a case of mistaken identity.

3. *The hunger strike*: Bhagat Singh and his fellow prisoners went on a hunger strike to protest the mistreatment of Indian prisoners.


Execution and Legacy

Bhagat Singh was arrested, tried, and sentenced to death for his involvement in the Lahore Conspiracy Case. He was executed by hanging on March 23, 1931, at the age of 23.


Bhagat Singh's sacrifice and legacy have inspired generations of Indians and freedom fighters worldwide. He is remembered as a symbol of courage, patriotism, and selflessness.


Quotes and Writings

Some notable quotes and writings by Bhagat Singh include:


1. *"Inquilab Zindabad!"* (Long live the revolution!)

2. *"The ultimate goal of the revolution is not just to overthrow the existing government but to establish a new socialist order."*

3. *"I am a man and all that affects humanity concerns me."*


Bhagat Singh's life and legacy continue to inspire and motivate people to fight for freedom, justice, and equality.



Here's an inspirational story about Bhagat Singh:


The Story of Bhagat Singh's Courage

Bhagat Singh was just 23 years old when he was sentenced to death for his involvement in the Lahore Conspiracy Case. Despite knowing that he would be executed, Bhagat Singh remained calm and composed.


As he stood in the courtroom, awaiting his sentence, Bhagat Singh's mother, Vidyavati, was also present. She was worried and anxious about her son's fate.


Bhagat Singh, sensing his mother's distress, smiled and said, "Mother, don't worry. I am not afraid of death. I am proud to give my life for the freedom of our country."


Vidyavati was taken aback by her son's courage and conviction. She asked him, "Bhagat, how can you be so calm and brave in the face of death?"


Bhagat Singh replied, "Mother, I have always believed that the ultimate sacrifice for one's country is the greatest honor. I am proud to be able to make that sacrifice."


Bhagat Singh's words and courage had a profound impact on his mother and everyone present in the courtroom. His unwavering commitment to his cause and his willingness to sacrifice his life for his country inspired a nation.


Even in the face of death, Bhagat Singh remained steadfast in his beliefs and convictions. His courage and conviction continue to inspire people to this day.


Lessons from Bhagat Singh's Story

1. *Courage in the face of adversity*: Bhagat Singh's story teaches us to remain calm and courageous in the face of adversity.

2. *Conviction and commitment*: Bhagat Singh's unwavering commitment to his cause is a testament to the power of conviction and determination.

3. *Sacrifice for a greater cause*: Bhagat Singh's willingness to sacrifice his life for his country's freedom inspires us to think about the greater good and the importance of making sacrifices for a noble cause.


Bhagat Singh's story is a powerful reminder of the importance of courage, conviction, and sacrifice. His legacy continues to inspire people to fight for what is right and just.




Here are some motivational words written by Bhagat Singh:


Quotes

1. *"Inquilab Zindabad!"* (Long live the revolution!)

2. *"The ultimate goal of the revolution is not just to overthrow the existing government but to establish a new socialist order."*

3. *"I am a man and all that affects humanity concerns me."*

4. *"Revolution is not just a change of government, but a change of system, a change of mentality."*

5. *"We are not just fighting for freedom from British rule, but for the freedom to live with dignity and self-respect."*


Letters and Writings

1. *Letter to his mother*: "Mother, I know that I am going to be hanged, but I am not afraid. I am proud to give my life for the freedom of our country."

2. *Letter to his comrades*: "Comrades, we are not just fighting for our own freedom, but for the freedom of our country and our people. Let us march forward with courage and determination."


Poetry

1. *"The Revolution's Call"*: "Arise, ye slaves, and break your chains / The time for revolution has come / Let us march forward, united and strong / And fight for our freedom, right and long."


These words reflect Bhagat Singh's passion, convictio

n, and commitment to the cause of Indian independence and socialism.


Chatrapati Shivaji Maharaj

 Chatrapati Shivaji Maharaj



Chatrapati Shivaji Maharaj: The Embodiment of Courage and Visionary Leadership

Chatrapati Shivaji Maharaj, the founder of the Maratha Empire, is one of the most revered figures in Indian history. Born on February 19, 1630, in Shivneri Fort, Maharashtra, Shivaji's life was a testament to his unwavering courage, strategic brilliance, and visionary leadership. This essay delves into the life and achievements of Shivaji Maharaj, highlighting his significance in Indian history and his enduring legacy.


*Early Life and Military Campaigns*

Shivaji was born to Shahaji Bhonsle, a Maratha nobleman, and Jijabai, a devout and strong-willed woman. Shivaji's early life was marked by turmoil, with his father's involvement in the Deccan politics and his mother's influence shaping his future. Shivaji's military campaigns began at a young age, with his first major victory against the Bijapur Sultanate in 1645. This victory marked the beginning of Shivaji's rise to prominence as a skilled military leader.


*Establishment of the Maratha Empire*

Shivaji's vision for a unified and independent Maratha Empire led him to establish a robust administrative system, a well-organized military, and a network of forts and strategic alliances. He introduced innovative military tactics, such as guerrilla warfare and lightning-fast raids, which allowed him to outmaneuver his enemies and expand his territory. Shivaji's military campaigns against the Mughal Empire, the Bijapur Sultanate, and the Portuguese colonizers showcased his strategic brilliance and bravery.


*Administrative Reforms and Social Justice*

Shivaji's administrative reforms aimed to promote social justice, equality, and economic prosperity. He established a fair and efficient system of taxation, encouraged agriculture and trade, and promoted the welfare of his subjects. Shivaji's government was known for its transparency, accountability, and responsiveness to the needs of the common people. He also promoted the rights of women, the protection of the weak, and the preservation of Hindu culture.


*Legacy and Impact*

Shivaji Maharaj's legacy extends far beyond his military conquests and administrative reforms. He embodied the values of courage, honor, and selflessness, inspiring generations of Indians to strive for freedom, justice, and self-determination. Shivaji's vision for a unified and independent India continues to inspire Indian nationalism and patriotism. His life and achievements serve as a reminder of the importance of leadership, strategic thinking, and social responsibility.


*Conclusion*

Chatrapati Shivaji Maharaj's life and achievements are a testament to his unwavering commitment to his people, his culture, and his vision for a unified and independent India. His legacy continues to inspire Indians and people around the world, reminding us of the importance of courage, leadership, and social responsibility. As we reflect on Shivaji's life and achievements, we are reminded of the enduring power of vision, courage, and determination.

Featured posts

Mongolia

 Mongolia! Mongolia is a vast and sparsely populated country in East Asia, known for its stunning natural beauty, rich history, and unique c...

Popular posts