google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: March 2025

Sunday, March 2, 2025

simple C++ program to manage a kirana store

 Here's a simple C++ program to manage a kirana store:


#include <iostream>

#include <string>

#include <map>


using namespace std;


class KiranaStore {

private:

    map<string, int> inventory;

    map<string, int> prices;


public:

    void addInventory(const string& item, int quantity) {

        if (inventory.find(item) != inventory.end()) {

            inventory[item] += quantity;

        } else {

            inventory[item] = quantity;

        }

    }


    void removeInventory(const string& item, int quantity) {

        if (inventory.find(item) != inventory.end()) {

            if (inventory[item] >= quantity) {

                inventory[item] -= quantity;

            } else {

                cout << "Insufficient quantity in stock." << endl;

            }

        } else {

            cout << "Item not found in inventory." << endl;

        }

    }


    void addPrice(const string& item, int price) {

        prices[item] = price;

    }


    void displayInventory() {

        cout << "Current Inventory:" << endl;

        for (const auto& pair : inventory) {

            cout << pair.first << ": " << pair.second << endl;

        }

    }


    void displayPrices() {

        cout << "Current Prices:" << endl;

        for (const auto& pair : prices) {

            cout << pair.first << ": " << pair.second << endl;

        }

    }


    void calculateBill(const string& item, int quantity) {

        if (prices.find(item) != prices.end()) {

            int total = prices[item] * quantity;

            cout << "Total bill for " << quantity << " " << item << "(s): " << total << endl;

        } else {

            cout << "Price not found for the item." << endl;

        }

    }

};


int main() {

    KiranaStore store;


    while (true) {

        cout << "Kirana Store Management System" << endl;

        cout << "1. Add inventory" << endl;

        cout << "2. Remove inventory" << endl;

        cout << "3. Add price" << endl;

        cout << "4. Display inventory" << endl;

        cout << "5. Display prices" << endl;

        cout << "6. Calculate bill" << endl;

        cout << "7. Exit" << endl;


        int choice;

        cin >> choice;


        switch (choice) {

            case 1: {

                string item;

                int quantity;

                cout << "Enter item name: ";

                cin >> item;

                cout << "Enter quantity: ";

                cin >> quantity;

                store.addInventory(item, quantity);

                break;

            }

            case 2: {

                string item;

                int quantity;

                cout << "Enter item name: ";

                cin >> item;

                cout << "Enter quantity: ";

                cin >> quantity;

                store.removeInventory(item, quantity);

                break;

            }

            case 3: {

                string item;

                int price;

                cout << "Enter item name: ";

                cin >> item;

                cout << "Enter price: ";

                cin >> price;

                store.addPrice(item, price);

                break;

            }

            case 4:

                store.displayInventory();

                break;

            case 5:

                store.displayPrices();

                break;

            case 6: {

                string item;

                int quantity;

                cout << "Enter item name: ";

                cin >> item;

                cout << "Enter quantity: ";

                cin >> quantity;

                store.calculateBill(item, quantity);

                break;

            }

            case 7:

                return 0;

            default:

                cout << "Invalid choice. Please choose a valid option." << endl;

        }

    }


    return 0;

}

```


*Example Use Cases:*

1. Run the program and select option 1 (Add inventory).

2. Enter an item name and quantity, e.g., "Rice" and 50.

3. Select option 4 (Display inventory) to view the updated inventory.

4. Select option 3 (Add price) and enter a price for the item, e.g., 50 for "Rice".

5. Select option 6 (Calculate bill) and enter the item name and quantity, e.g., "Rice" and 10.

6. The program will display the total bill for the item.


*How to Compile and Run:*

1. Save the code in a file named `kirana_store.cpp`.

2. Open a terminal or command prompt.

3. Navigate to the directory where you saved the file.

4. Compile the program using `g++ kirana_store.cpp -o kirana_store`.

5. Run the program using `./kirana_store` (on Linux/macOS) or `kirana_store.exe` (on Windows).

Write a C program to create a calculator that performs basic arithmetic operations

 Here is a simple C program to create a calculator that performs basic arithmetic operations:


#include <stdio.h>


void printMenu() {

    printf("Simple Calculator\n");

    printf("1. Addition\n");

    printf("2. Subtraction\n");

    printf("3. Multiplication\n");

    printf("4. Division\n");

    printf("5. Exit\n");

}


int main() {

    int choice;

    float num1, num2, result;


    while (1) {

        printMenu();

        printf("Enter your choice: ");

        scanf("%d", &choice);


        if (choice == 5) {

            printf("Exiting the calculator. Goodbye!\n");

            break;

        }


        printf("Enter the first number: ");

        scanf("%f", &num1);


        printf("Enter the second number: ");

        scanf("%f", &num2);


        switch (choice) {

            case 1:

                result = num1 + num2;

                printf("%.2f + %.2f = %.2f\n", num1, num2, result);

                break;

            case 2:

                result = num1 - num2;

                printf("%.2f - %.2f = %.2f\n", num1, num2, result);

                break;

            case 3:

                result = num1 * num2;

                printf("%.2f * %.2f = %.2f\n", num1, num2, result);

                break;

            case 4:

                if (num2 != 0) {

                    result = num1 / num2;

                    printf("%.2f / %.2f = %.2f\n", num1, num2, result);

                } else {

                    printf("Error! Division by zero is not allowed.\n");

                }

                break;

            default:

                printf("Invalid choice. Please choose a valid option.\n");

        }

    }


    return 0;

}

```


*Example Use Cases:*

1. Run the program and select option 1 (Addition).

2. Enter two numbers, e.g., 10 and 20.

3. The program will display the result: 10.00 + 20.00 = 30.00.

4. Repeat the process for other arithmetic operations.


*How to Compile and Run:*

1. Save the code in a file named `calculator.c`.

2. Open a terminal or command prompt.

3. Navigate to the directory where you saved the file.

4. Compile the program using `gcc calculator.c -o calculator`.

5. Run the program using `./calculator` (on Linux/macOS) or `calculator.exe` (on Windows).

Holi

 Holi


Holi is a significant festival in Hinduism, celebrated with great enthusiasm and joy. Here are some key aspects of Holi:


History and Significance

Holi is an ancient festival, mentioned in the Puranas and other Hindu scriptures. It celebrates the triumph of good over evil, and the arrival of spring.


The Legend of Holika

The festival is associated with the legend of Holika, a demoness who tried to burn her nephew Prahlad, a devotee of Lord Vishnu. However, Prahlad was saved by his devotion, while Holika was burned.


Celebrations

Holi is celebrated over two days:


1. *Holika Dahan*: Bonfires are lit on the eve of Holi to symbolize the burning of Holika.

2. *Rangwali Holi*: On the second day, people gather to play with colored powders (gulal) and waters, symbolizing the colors of spring.


Traditions and Customs

- *Colors*: Holi is known for its vibrant colors, which are believed to bring good luck and prosperity.

- *Music and Dance*: Traditional Holi songs and dances, like the "Holiya" and "Dola Yatra", are performed during the celebrations.

- *Food*: Traditional Holi delicacies, such as gujiyas, thandai, and malpuas, are prepared and shared.


Regional Variations

Holi is celebrated differently across various regions in India:


- *Braj Holi*: In the Braj region, Holi is celebrated with great fervor, and the festivities last for several days.

- *Dola Yatra*: In West Bengal, Holi is celebrated as "Dola Yatra", with processions and traditional songs.


Modern Celebrations

Holi has become a popular festival globally, with many countries hosting Holi events and celebrations.


Safety Precautions

While celebrating Holi, it's essential to take safety precautions:


- *Use natural colors*: Avoid using synthetic colors, which can harm the skin and eyes.

- *Protect skin and eyes*: Wear protective clothing and eyewear to prevent color stains and eye irritation.

- *Stay hydrated*: Drink plenty of water to stay hydrated during the celebrations.


I hope this information helps you understand and appreciate the vibrant festival of Holi!

Moti Ram Mehra ji

 Moti Ram Mehra was a Sikh warrior and a devoted follower of Guru Gobind Singh Ji, the tenth Sikh Guru. He played a significant role in Sikh history, particularly during the Battle of Chamkaur in 1705.


Early Life and Background

Moti Ram Mehra was born in the village of Mehra, in the present-day Sangrur district of Punjab, India. He belonged to a family of farmers and was known for his bravery and martial skills from a young age.


Association with Guru Gobind Singh Ji

Moti Ram Mehra became a devoted follower of Guru Gobind Singh Ji and joined his army. He participated in several battles alongside the Guru and proved himself to be a skilled and fearless warrior.


Battle of Chamkaur

During the Battle of Chamkaur, Moti Ram Mehra fought valiantly alongside Guru Gobind Singh Ji and other Sikh warriors. When the Guru's two elder sons, Sahibzada Ajit Singh and Sahibzada Jujhar Singh, were martyred in battle, Moti Ram Mehra was deeply grieved. He requested the Guru's permission to avenge their deaths and was granted permission.


Martyrdom

Moti Ram Mehra fought bravely and killed many enemy soldiers. However, he was eventually surrounded and outnumbered. Rather than surrender, he chose to fight to the death and was martyred in battle.


Legacy

Moti Ram Mehra's bravery and sacrifice are remembered and revered by Sikhs around the world. He is considered a hero of Sikh history and a shining example of the values of courage, loyalty, and devotion to one's faith and community.






Moti Ram Mehra was a devoted follower of Guru Gobind Singh Ji and a brave Sikh warrior. Here is some information about his family:


Immediate Family

1. *Father*: Not much is known about Moti Ram Mehra's father, but it is believed that he was a farmer from the village of Mehra in present-day Sangrur district of Punjab, India.

2. *Mother*: There is limited information available about Moti Ram Mehra's mother.

3. *Wife*: Moti Ram Mehra was married, but the name of his wife is not well-documented.

4. *Children*: It is believed that Moti Ram Mehra had children, but their names and details are not readily available.


Legacy and Descendants

1. *Descendants*: Moti Ram Mehra's descendants continue to live in Punjab, India, and other parts of the world. Many of them are proud of their ancestor's bravery and sacrifice.

2. *Family traditions*: The family of Moti Ram Mehra continues to follow the Sikh faith and traditions. They celebrate important Sikh holidays and events, such as Gurpurab and Vaisakhi.

3. *Preserving history*: Moti Ram Mehra's descendants have worked to preserve their family's history and legacy. They have shared stories and documents about their ancestor's life and bravery.


Please note that the information available about Moti Ram Mehra's family is limited, and some details may be based on oral traditions or secondary sources.







According to historical records, Moti Ram Mehra's family was killed by the Mughal forces and their allies, who were seeking revenge against the Sikhs and Guru Gobind Singh Ji.


After Moti Ram Mehra's martyrdom in the Battle of Chamkaur, his family was targeted by the Mughal forces. His wife, children, and other family members were killed in the ensuing violence.


This tragic event highlights the sacrifices made by many Sikh families during this period, who suffered greatly for their faith and their loyalty to Guru Gobind Singh Ji.

simple C++ program to manage a kirana store

 Here's a simple C++ program to manage a kirana store: #include <iostream> #include <string> #include <map> using name...