quiz_app.js

// Simple Quiz App with Timer
let questions = [
    { question: "What is 2 + 2?", answer: "4" },
    { question: "What is the capital of France?", answer: "Paris" },
];
let timeLeft = 30;
let currentQuestion = 0;

function startQuiz() {
    let timer = setInterval(() => {
        timeLeft--;
        console.log(`Time left: ${timeLeft}s`);
        if (timeLeft <= 0) {
            clearInterval(timer);
            console.log("Time's up!");
        }
    }, 1000);

    askQuestion();
}

function askQuestion() {
    if (currentQuestion < questions.length) {
        let q = questions[currentQuestion];
        console.log(q.question);
        currentQuestion++;
    } else {
        console.log("Quiz Over!");
    }
}

startQuiz();
            
password_strength.js

// Password Strength Checker
function checkPasswordStrength(password) {
    let strength = 0;
    if (password.length >= 8) strength++;
    if (/[A-Z]/.test(password)) strength++;
    if (/[0-9]/.test(password)) strength++;
    if (/[@$!%*?&]/.test(password)) strength++;

    switch (strength) {
        case 1: return "Weak";
        case 2: return "Medium";
        case 3: return "Strong";
        case 4: return "Very Strong";
        default: return "Very Weak";
    }
}

console.log(checkPasswordStrength("Test123!")); // Very Strong
            
temperature_converter.js

// Temperature Converter
function convertTemperature(value, unit) {
    if (unit === "C") {
        return (value * 9/5) + 32; // Celsius to Fahrenheit
    } else if (unit === "F") {
        return (value - 32) * 5/9; // Fahrenheit to Celsius
    } else {
        return "Invalid unit";
    }
}

console.log(convertTemperature(100, "C")); // Output: 212
            
Create Mad Libs Generator Game in Python

                Screen = Tk()
Screen.title("PythonGeeks Mad Libs Generator")
Screen.geometry('400x400')
Screen.config(bg="pink")
Label(Screen, text='PythonGeeks Mad Libs Generator').place(x=100, y=20)
#creating buttons
Story1Button = Button(Screen, text='A memorable day', font=("Times New Roman", 13),command=lambda: Story1(Screen),bg='Blue')
Story1Button.place(x=140, y=90)
Story2Button = Button(Screen, text='Ambitions', font=("Times New Roman", 13),command=lambda: Story2(Screen), bg='Blue')
Story2Button.place(x=150, y=150)
 
Screen.update()
Screen.mainloop()


            
Creating function for first story:


                def Story1(win):
  def final(tl: Toplevel, name, sports, City, playername, drinkname, snacks):
 
    text = f'''
       One day me and my friend {name} decided to play a {sports} game in {City}.
       We wanted to watch {playername}.
       We drank {drinkname} and also ate some {snacks} 
       We really enjoyed! We are looking forward to go again and enjoy '''
 
    tl.geometry(newGeometry='500x550')
 
    Label(tl, text='Story:',  wraplength=tl.winfo_width()).place(x=160, y=310)
    Label(tl, text=text,wraplength=tl.winfo_width()).place(x=0, y=330)
 
  NewScreen = Toplevel(win, bg='yellow')
  NewScreen.title("A memorable day")
  NewScreen.geometry('500x500')
  Label(NewScreen, text='Memorable Day').place(x=100, y=0)
  Label(NewScreen, text='Name:').place(x=0, y=35)
  Label(NewScreen, text='Enter a game:').place(x=0, y=70)
  Label(NewScreen, text='Enter a city:').place(x=0, y=110)
  Label(NewScreen, text='Enter the name of a player:').place(x=0, y=150)
  Label(NewScreen, text='Enter the name of a drink:').place(x=0, y=190)
  Label(NewScreen, text='Enter the name of a snack:').place(x=0, y=230)
  Name = Entry(NewScreen, width=17)
  Name.place(x=250, y=35)
  game = Entry(NewScreen, width=17)
  game.place(x=250, y=70)
  city = Entry(NewScreen, width=17)
  city.place(x=250, y=105)
  player = Entry(NewScreen, width=17)
  player.place(x=250, y=150)
  drink = Entry(NewScreen, width=17)
  drink.place(x=250, y=190)
  snack = Entry(NewScreen, width=17)
  snack.place(x=250, y=220)
  SubmitButton = Button(NewScreen, text="Submit", background="Blue", font=('Times', 12), command=lambda:final(NewScreen, Name.get(), game.get(), city.get(), player.get(), drink.get(), snack.get()))
  SubmitButton.place(x=150, y=270)
 
  NewScreen.mainloop()
                

            
Creating function for second story:


                def Story2(win):
def final(tl: Toplevel, profession, noun, feeling, emotion,verb):
            text = f'''
            One day me and my friend {name} decided to play a {sports} game in {City}.
       But we were not able to play. So, we went to the game and watched our favourite player {playername}.
       We drank {drinkname} and also ate some {snacks} 
       We really enjoyed it! We are looking forward to go again and enjoy 
'''
 
            tl.geometry(newGeometry='500x550')
 
            Label(tl, text='Story:',  wraplength=tl.winfo_width()).place(x=160, y=310)
            Label(tl, text=text,wraplength=tl.winfo_width()).place(x=0, y=330)
    NewScreen = Toplevel(win, bg='red')
    NewScreen.title("Ambitions")
    NewScreen.geometry('500x500')
    Label(NewScreen, text='Ambitions').place(x=150, y=0)
    Label(NewScreen, text='Enter a profession:').place(x=0, y=35)
    Label(NewScreen, text='Enter a noun:').place(x=0, y=70)
    Label(NewScreen, text='Enter a feeling:').place(x=0, y=110)
    Label(NewScreen, text='Enter a emotion:').place(x=0, y=150)
    Label(NewScreen, text='Enter a verb:').place(x=0, y=190)
    Profession = Entry(NewScreen, width=17)
    Profession.place(x=250, y=35)
    Noun = Entry(NewScreen, width=17)
    Noun.place(x=250, y=70)
    Feeling = Entry(NewScreen, width=17)
    Feeling.place(x=250, y=105)
    Emotion= Entry(NewScreen, width=17)
    Emotion.place(x=250, y=150)
    Verb = Entry(NewScreen, width=17)
    Verb.place(x=250, y=190)
    SubmitButton = Button(NewScreen, text="Submit", background="Blue", font=('Times', 12), command=lambda:final(NewScreen, Profession.get(), Noun.get(), Feeling.get(), Emotion.get(), Verb.get()))
    SubmitButton.place(x=150, y=270)
                

            
Event Webpage – HTML Structure

                


    

Welcome to GeeksforGeeks TechCon 2025

The Ultimate Technology and Programming Conference

About the Event

MrCode TechCon 2025 brings together leading minds in programming, tech, and innovation. Join us for a day of insightful talks, hands-on workshops, and an opportunity to network with fellow geeks and professionals from all around the world.

Event Schedule

Time Session Contest
9:00 AM Opening Keynote GeeksforGeeks Coding Plateform
10:30 AM Understanding AI and Machine Learning Mr. Arvind Kumar
1:00 PM Lunch Break -
2:00 PM Exploring the Future of Cloud Computing Ms. Neha Gupta

Meet the Speakers

  • Dr. Radhika Sharma: AI Expert and Researcher
  • Mr. Arvind Kumar: Senior Data Scientist at TechWave
  • Ms. Neha Gupta: Cloud Computing Specialist at CloudTech
  • Mr. Sandeep Reddy: Full Stack Developer and Open-Source Contributor

Contact Us










Telecom Billing System in C



                #include  
                    #include  
                      
                    // Structure to hold customer information 
                    struct Customer { 
                        char name[50]; 
                        char phoneNumber[15]; 
                        float usage; 
                        float totalBill; 
                    }; 
                      
                    struct Customer 
                        customers[100]; // Array to store customer data 
                    int customerCount = 0; // Variable to keep track of the 
                                           // number of customers 
                      
                    // Function to add a new customer record 
                    void addRecord() 
                    { 
                        if (customerCount < 100) { 
                            printf("\nEnter name: "); 
                            scanf(" %[^\n]s", customers[customerCount].name); 
                            printf("Enter phone number: "); 
                            scanf("%s", customers[customerCount].phoneNumber); 
                            printf("Enter usage (in minutes): "); 
                            scanf("%f", &customers[customerCount].usage); 
                            customers[customerCount].totalBill 
                                = customers[customerCount].usage * 0.1; 
                            customerCount++; 
                            printf("\nRecord added successfully!\n"); 
                        } 
                        else { 
                            printf("\nMaximum number of records reached!\n"); 
                        } 
                    } 
                      
                    // Function to view the list of customer records 
                    void viewRecords() 
                    { 
                        printf("\nName\tPhone Number\tUsage(min)\tTotal "
                               "Bill($)\n"); 
                        for (int i = 0; i < customerCount; i++) { 
                            printf("%s\t%s\t%.2f\t\t%.2f\n", customers[i].name, 
                                   customers[i].phoneNumber, customers[i].usage, 
                                   customers[i].totalBill); 
                        } 
                    } 
                      
                    // Function to modify a customer record 
                    void modifyRecord(char phoneNumber[]) 
                    { 
                        for (int i = 0; i < customerCount; i++) { 
                            if (strcmp(customers[i].phoneNumber, phoneNumber) 
                                == 0) { 
                                printf( 
                                    "\nEnter new usage (in minutes) for %s: ", 
                                    customers[i].name); 
                                scanf("%f", &customers[i].usage); 
                                customers[i].totalBill 
                                    = customers[i].usage * 0.1; 
                                printf("\nRecord modified successfully!\n"); 
                                return; 
                            } 
                        } 
                        printf("\nRecord not found!\n"); 
                    } 
                      
                    // Function to view payment for a customer 
                    void viewPayment(char phoneNumber[]) 
                    { 
                        for (int i = 0; i < customerCount; i++) { 
                            if (strcmp(customers[i].phoneNumber, phoneNumber) 
                                == 0) { 
                                printf( 
                                    "%s\t%s\t%.2f\t\t%.2f\n", customers[i].name, 
                                    customers[i].phoneNumber, 
                                    customers[i].usage, customers[i].totalBill); 
                                return; 
                            } 
                        } 
                        printf("\nRecord not found!\n"); 
                    } 
                      
                    // Function to delete a customer record 
                    void deleteRecord(char phoneNumber[]) 
                    { 
                        for (int i = 0; i < customerCount; i++) { 
                            if (strcmp(customers[i].phoneNumber, phoneNumber) 
                                == 0) { 
                                for (int j = i; j < customerCount - 1; j++) { 
                                    customers[j] = customers[j + 1]; 
                                } 
                                customerCount--; 
                                printf("\nRecord deleted successfully!\n"); 
                                return; 
                            } 
                        } 
                        printf("\nRecord not found!\n"); 
                    } 
                      
                    // Function to display menu options 
                    void displayMenu() 
                    { 
                        printf("\n1. Add New Record\n"); 
                        printf("2. View List of Records\n"); 
                        printf("3. Modify Record\n"); 
                        printf("4. View Payment\n"); 
                        printf("5. Delete Record\n"); 
                        printf("6. Exit\n"); 
                    } 
                      
                    int main() 
                    { 
                        int choice; 
                        char phoneNumber[15]; 
                      
                        while (1) { 
                            displayMenu(); 
                            printf("Enter your choice: "); 
                            scanf("%d", &choice); 
                      
                            switch (choice) { 
                            case 1: 
                                addRecord(); 
                                break; 
                            case 2: 
                                viewRecords(); 
                                break; 
                            case 3: 
                                printf( 
                                    "\nEnter phone number to modify record: "); 
                                scanf("%s", phoneNumber); 
                                modifyRecord(phoneNumber); 
                                break; 
                            case 4: 
                                printf( 
                                    "\nEnter phone number to view payment: "); 
                                scanf("%s", phoneNumber); 
                                viewPayment(phoneNumber); 
                                break; 
                            case 5: 
                                printf( 
                                    "\nEnter phone number to delete record: "); 
                                scanf("%s", phoneNumber); 
                                deleteRecord(phoneNumber); 
                                break; 
                            case 6: 
                                return 0; 
                            default: 
                                printf("\nInvalid choice! Please try again.\n"); 
                            } 
                        } 
                      
                        return 0; 
                    }
                

            
Snake Game


                // C program to implement an interactive
// snake game
#include 
#include 
#include 
#include 
#include 

// Macros variable (HEIGHT, WIDTH)
#define HEIGHT 20
#define WIDTH 40

// Array to store the coordinates of snake
// tail (x-axis, y-axis)
int snakeTailX[100], snakeTailY[100];

// Variable to store the length of the
// snake's tail
int snakeTailLen;

// Score and signal flags
int gameover, key, score;

// Coordinates of snake's head and fruit
int x, y, fruitx, fruity;

// Function to generate the fruit
// within the boundary
void setup() {
    
    // Flag to signal the gameover
    gameover = 0;

    // Initial coordinates of the snake
    x = WIDTH / 2;
    y = HEIGHT / 2;
    
    // Initial coordinates of the fruit
    fruitx = rand() % WIDTH;
    fruity = rand() % HEIGHT;
    while (fruitx == 0)
        fruitx = rand() % WIDTH;

    while (fruity == 0)
        fruity = rand() % HEIGHT;

    // Score initialzed
    score = 0;
}

// Function to draw the game field, snake
// and fruit
void draw() {
    system("cls");
    
    // Creating top wall
    for (int i = 0; i < WIDTH + 2; i++)
        printf("-");
    printf("\n");
    
    for (int i = 0; i < HEIGHT; i++) {
        for (int j = 0; j <= WIDTH; j++) {

            // Creating side walls with '#'
            if (j == 0 || j == WIDTH)
                printf("#");
            
            // Creating snake's head with 'O'
            if (i == y && j == x)
                printf("O");
            
            // Creating the sanke's food with '*'
            else if (i == fruity && j == fruitx)
                printf("*");
            
            // Creating snake's body with 'o'
            else {
                int prTail = 0;
                for (int k = 0; k < snakeTailLen; k++) {
                    if (snakeTailX[k] == j
                        && snakeTailY[k] == i) {
                        printf("o");
                        prTail = 1;
                    }
                }
                if (!prTail)
                    printf(" ");
            }
        }
      printf("\n");
            
    }
    
    // Creating bottom walls with '-'
    for (int i = 0; i < WIDTH + 2; i++)
        printf("-");
     printf("\n");

    // Print the score and instructions
    printf("score = %d", score);
    printf("\n");
    printf("Press W, A, S, D for movement.\n");
    printf("Press X to quit the game.");
}

// Function to take the real time input and
// set the 'flag' variable accordingly
void input() {
    if (kbhit()) {
        switch (tolower(getch())) {
        case 'a':
            if(key!=2)
            key = 1;
            break;
        case 'd':
            if(key!=1)
            key = 2;
            break;
        case 'w':
            if(key!=4)
            key = 3;
            break;
        case 's':
            if(key!=3)
            key = 4;
            break;
        case 'x':
            gameover = 1;
            break;
        }
    }
}

// Function for the movement logic that
// checks eat, move, collisions
void logic() {
    
    // Updating the coordinates for continous
    // movement of snake
    int prevX = snakeTailX[0];
    int prevY = snakeTailY[0];
    int prev2X, prev2Y;
    snakeTailX[0] = x;
    snakeTailY[0] = y;
    for (int i = 1; i < snakeTailLen; i++) {
        prev2X = snakeTailX[i];
        prev2Y = snakeTailY[i];
        snakeTailX[i] = prevX;
        snakeTailY[i] = prevY;
        prevX = prev2X;
        prevY = prev2Y;
    }
    
    // Changing the direction of movement of snake
    switch (key) {
    case 1:
        x--;
        break;
    case 2:
        x++;
        break;
    case 3:
        y--;
        break;
    case 4:
        y++;
        break;
    default:
        break;
    }

    // If the game is over
    if (x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT)
        gameover = 1;
        
    // Checks for collision with the tail (o)
    for (int i = 0; i < snakeTailLen; i++) {
        if (snakeTailX[i] == x && snakeTailY[i] == y)
            gameover = 1;
    }

    // If snake reaches the fruit
    // then update the score
    if (x == fruitx && y == fruity) {
        fruitx = rand() % WIDTH;
        fruity = rand() % HEIGHT;
        while (fruitx == 0)
            fruitx = rand() % WIDTH;

        // Generation of new fruit
        while (fruity == 0)
            fruity = rand() % HEIGHT;
        score += 10;
         snakeTailLen++;
    }
}

void main() {
  
    // Initial set up that initialize the
    // required variables
    setup();

    // Game loop starts here
    while (!gameover) {

        // Functions that will be called
        // repeatedly after the given interval
        draw();
        input();
        logic();
        Sleep(33);
    }
}

                

            
Calendar


                // C program to print the month by month 
// calendar for the given year 

#include  

// Function that returns the index of the 
// day for date DD/MM/YYYY 
int dayNumber(int day, int month, int year) 
{ 

    static int t[] = { 0, 3, 2, 5, 0, 3, 
                    5, 1, 4, 6, 2, 4 }; 
    year -= month < 3; 
    return (year + year / 4 
            - year / 100 
            + year / 400 
            + t[month - 1] + day) 
        % 7; 
} 

// Function that returns the name of the 
// month for the given month Number 
// January - 0, February - 1 and so on 
char* getMonthName(int monthNumber) 
{ 
    char* month; 

    switch (monthNumber) { 
    case 0: 
        month = "January"; 
        break; 
    case 1: 
        month = "February"; 
        break; 
    case 2: 
        month = "March"; 
        break; 
    case 3: 
        month = "April"; 
        break; 
    case 4: 
        month = "May"; 
        break; 
    case 5: 
        month = "June"; 
        break; 
    case 6: 
        month = "July"; 
        break; 
    case 7: 
        month = "August"; 
        break; 
    case 8: 
        month = "September"; 
        break; 
    case 9: 
        month = "October"; 
        break; 
    case 10: 
        month = "November"; 
        break; 
    case 11: 
        month = "December"; 
        break; 
    default:
        month = "Invalid"; // Warning: Improper usage of function can lead to undefined behavior.
        break;

    } 
    return month; 
} 

// Function to return the number of days 
// in a month 
int numberOfDays(int monthNumber, int year) 
{ 
    // January 
    if (monthNumber == 0) 
        return (31); 

    // February 
    if (monthNumber == 1) { 
        // If the year is leap then Feb 
        // has 29 days 
        if (year % 400 == 0 
            || (year % 4 == 0 
                && year % 100 != 0)) 
            return (29); 
        else
            return (28); 
    } 

    // March 
    if (monthNumber == 2) 
        return (31); 

    // April 
    if (monthNumber == 3) 
        return (30); 

    // May 
    if (monthNumber == 4) 
        return (31); 

    // June 
    if (monthNumber == 5) 
        return (30); 

    // July 
    if (monthNumber == 6) 
        return (31); 

    // August 
    if (monthNumber == 7) 
        return (31); 

    // September 
    if (monthNumber == 8) 
        return (30); 

    // October 
    if (monthNumber == 9) 
        return (31); 

    // November 
    if (monthNumber == 10) 
        return (30); 

    // December 
    if (monthNumber == 11) 
        return (31);
} 

// Function to print the calendar of 
// the given year 
void printCalendar(int year) 
{ 
    printf("     Calendar - %d\n\n", year); 
    int days; 

    // Index of the day from 0 to 6 
    int current = dayNumber(1, 1, year); 

    // i for Iterate through months 
    // j for Iterate through days 
    // of the month - i 
    for (int i = 0; i < 12; i++) { 
        days = numberOfDays(i, year); 

        // Print the current month name 
        printf("\n ------------%s-------------\n", 
            getMonthName(i)); 

        // Print the columns 
        printf(" Sun Mon Tue Wed Thu Fri Sat\n"); 

        // Print appropriate spaces 
        int k; 
        for (k = 0; k < current; k++) 
            printf("     "); 

        for (int j = 1; j <= days; j++) { 
            printf("%5d", j); 

            if (++k > 6) { 
                k = 0; 
                printf("\n"); 
            } 
        } 

        if (k) 
            printf("\n"); 

        current = k; 
    } 

    return; 
} 

// Driver Code 
int main() 
{ 
    int year = 2016; // Warning: For beginners, it may not be clear how to input a custom year.
                     // Suggest replacing this with a scanf() for user input.

    // Function Call 
    printCalendar(year); 
    return 0; 
}
                

            
C Program for Hangman Game


                // C program to implement hangman game
#include 
#include 
#include 
#include 
#include 
#include 

#define MAX_WORD_LENGTH 50
#define MAX_TRIES 6

// Struct to hold a word and its hint
struct WordWithHint {
    char word[MAX_WORD_LENGTH];
    char hint[MAX_WORD_LENGTH];
};

// Function to display the current state of the word
void displayWord(const char word[], const bool guessed[]);

// Function to draw the hangman
void drawHangman(int tries);

// driver code
int main()
{
    // Seed the random number generator with the current
    // time
    srand(time(NULL));
    // Array of words with hints
    struct WordWithHint wordList[] = {
        { "geeksforgeeks", "Computer coding" },
        { "elephant", "A large mammal with a trunk" },
        { "pizza", "A popular Italian dish" },
        { "beach", "Sandy shore by the sea" },
        // Add more words and hints here
    };

    // Select a random word from the list
    int wordIndex = rand() % 4;

    const char* secretWord = wordList[wordIndex].word;
    const char* hint = wordList[wordIndex].hint;

    int wordLength = strlen(secretWord);
    char guessedWord[MAX_WORD_LENGTH] = { 0 };
    bool guessedLetters[26] = { false };

    printf("Welcome to Hangman!\n");
    printf("Hint: %s\n", hint);

    int tries = 0;

    while (tries < MAX_TRIES) {
        printf("\n");
        displayWord(guessedWord, guessedLetters);
        drawHangman(tries);

        char guess;
        printf("Enter a letter: ");
        scanf(" %c", &guess);
        guess = tolower(guess);

        if (guessedLetters[guess - 'a']) {
            printf("You've already guessed that letter. "
                   "Try again.\n");
            continue;
        }

        guessedLetters[guess - 'a'] = true;

        bool found = false;
        for (int i = 0; i < wordLength; i++) {
            if (secretWord[i] == guess) {
                found = true;
                guessedWord[i] = guess;
            }
        }

        if (found) {
            printf("Good guess!\n");
        }
        else {
            printf("Sorry, the letter '%c' is not in the "
                   "word.\n",
                   guess);
            tries++;
        }

        if (strcmp(secretWord, guessedWord) == 0) {
            printf("\nCongratulations! You've guessed the "
                   "word: %s\n",
                   secretWord);
            break;
        }
    }

    if (tries >= MAX_TRIES) {
        printf("\nSorry, you've run out of tries. The word "
               "was: %s\n",
               secretWord);
    }

    return 0;
}

void displayWord(const char word[], const bool guessed[])
{
    printf("Word: ");
    for (int i = 0; word[i] != '\0'; i++) {
        if (guessed[word[i] - 'a']) {
            printf("%c ", word[i]);
        }
        else {
            printf("_ ");
        }
    }
    printf("\n");
}

void drawHangman(int tries)
{
    const char* hangmanParts[]
        = { "     _________",    "    |         |",
            "    |         O",   "    |        /|\\",
            "    |        / \\", "    |" };

    printf("\n");
    for (int i = 0; i <= tries; i++) {
        printf("%s\n", hangmanParts[i]);
    }
}
                

            
C Program to Make a Simple Calculator

                // C Program to make a Simple Calculator using 
// switch-case statements
#include 
#include 

int main() {
    char op;
    double a, b, res;

    // Read the operator
    printf("Enter an operator (+, -, *, /): ");
    scanf("%c", &op);

    // Read the two numbers
    printf("Enter two operands: ");
    scanf("%lf %lf", &a, &b);
    
    // Define all four operations in the corresponding
    // switch-case
    switch (op) {
    case '+':
        res = a + b;
        break;
    case '-':
        res = a - b;
        break;
    case '*':
         res = a * b;
        break;
    case '/':
        res = a / b;
        break;
    default:
        printf("Error! Incorrect Operator Value\n");
        res = -DBL_MAX;
    }
    if(res!=-DBL_MAX)
      printf("%.2lf", res);
    
    return 0;
}
                

            
C Program for Snake and Ladder Game


                / C Program to implement Snake and Ladder Game 
#include  
#include  
#include  
// Function to roll a six-sided die 
int rollDie() { return rand() % 6 + 1; } 
  
// global variables to store postions of player1 and player2 
int player1 = 0, player2 = 0; 
  
// Function to print the board 
void printBoard() 
{ 
    // logic to print a snake-ladder Game board 
    // programmer can implement their own logic for the board, 
      // this is one way to print a snake ladder board. 
    int board[101]; 
    for (int i = 1; i <= 100; i++) { 
        board[i] = i; 
    } 
  
    int alt = 0; // to switch between the alternate nature of the board 
    int iterLR = 101; // iterator to print from left to right 
    int iterRL = 80;  // iterator to print from right to left 
    int val = 100;     
    while (val--) { 
        if (alt == 0) { 
            iterLR--; 
            if (iterLR == player1) { 
                printf("#P1    "); 
            } 
            else if (iterLR == player2) { 
                printf("#P2    "); 
            } 
            else
                printf("%d    ", board[iterLR]); 
  
            if (iterLR % 10 == 1) { 
                printf("\n\n"); 
                alt = 1; 
                iterLR -= 10; 
            } 
        } 
        else { 
            iterRL++; 
            if (iterRL == player1) { 
                printf("#P1    "); 
            } 
            else if (iterRL == player2) { 
                printf("#P2    "); 
            } 
            else
                printf("%d    ", board[iterRL]); 
  
            if (iterRL % 10 == 0) { 
                printf("\n\n"); 
                alt = 0; 
                iterRL -= 30; 
            } 
        } 
        if (iterRL == 10) 
            break; 
    } 
    printf("\n"); 
} 
  
// Function to move the player 
int movePlayer(int currentPlayer, int roll) 
{ 
    int newPosition = currentPlayer + roll; 
    // Define the positions of snakes and ladders on the 
    // board 
    int snakesAndLadders[101]; 
  
    for (int i = 0; i <= 100; i++) { 
        snakesAndLadders[i] = 0; 
    } 
    
      // here positive weights represent a ladder 
      // and negative weights represent a snake. 
    snakesAndLadders[6] = 40; 
    snakesAndLadders[23] = -10; 
    snakesAndLadders[45] = -7; 
    snakesAndLadders[61] = -18; 
    snakesAndLadders[65] = -8; 
    snakesAndLadders[77] = 5; 
    snakesAndLadders[98] = -10; 
  
    int newSquare 
        = newPosition + snakesAndLadders[newPosition]; 
  
    if (newSquare > 100) { 
        return currentPlayer; // Player cannot move beyond 
                              // square 100 
    } 
  
    return newSquare; 
} 
  
int main() 
{ 
    srand(time(0)); // Initialize random seed 
    int currentPlayer = 1; 
    int won = 0; 
  
    printf("Snake and Ladder Game\n"); 
  
    while (!won) { 
  
        printf( 
            "\nPlayer %d, press Enter to roll the die...", 
            currentPlayer); 
        getchar(); // Wait for the player to press Enter 
        int roll = rollDie(); 
        printf("You rolled a %d.\n", roll); 
  
        if (currentPlayer == 1) { 
            player1 = movePlayer(player1, roll); 
            printf("Player 1 is now at square %d.\n\n", 
                   player1); 
            printBoard(); 
            if (player1 == 100) { 
                printf("Player 1 wins!\n"); 
                won = 1; 
            } 
        } 
        else { 
            player2 = movePlayer(player2, roll); 
            printf("Player 2 is now at square %d.\n\n", 
                   player2); 
            printBoard(); 
            if (player2 == 100) { 
                printf("Player 2 wins!\n"); 
                won = 1; 
            } 
        } 
  
        // Switch to the other player 
        currentPlayer = (currentPlayer == 1) ? 2 : 1; 
    } 
  
    return 0; 
}
                

            
Bank Management System


                // C program to implement
// the above approach
#include 
#include 
#include 
#include 
#include 
 
// Declaring all the functions
void checkbalance(char*);
void transfermoney(void);
void display(char*);
void person(char*);
void login(void);
void loginsu(void);
void account(void);
void accountcreated(void);
void afterlogin(void);
void logout(void);
 
// Declaring gotoxy
// function for setting
// cursor position
void gotoxy(int x, int y)
{
    COORD c;
    c.X = x;
    c.Y = y;
 
    SetConsoleCursorPosition(
        GetStdHandle(STD_OUTPUT_HANDLE), c);
}
 
// Creating a structure to store
// data of the user
struct pass {
    char username[50];
    int date, month, year;
    char pnumber[15];
    char adharnum[20];
    char fname[20];
    char lname[20];
    char fathname[20];
    char mothname[20];
    char address[50];
    char typeaccount[20];
};
 
// Structure to keep track
// of amount transfer
struct money {
    char usernameto[50];
    char userpersonfrom[50];
    long int money1;
};
 
struct userpass {
    char password[50];
};
 
// Driver Code
int main()
{
    int i, a, b, choice;
    int passwordlength;
 
    gotoxy(20, 3);
 
    // Creating a Main
    // menu for the user
    printf("WELCOME TO BANK ACCOUNT SYSTEM\n\n");
    gotoxy(18, 5);
 
    printf("**********************************");
    gotoxy(25, 7);
 
    printf("DEVELOPER-Naman kumar");
 
    gotoxy(20, 10);
    printf("1.... CREATE A BANK ACCOUNT");
 
    gotoxy(20, 12);
    printf("2.... ALREADY A USER? SIGN IN");
    gotoxy(20, 14);
    printf("3.... EXIT\n\n");
 
    printf("\n\nENTER YOUR CHOICE..");
 
    scanf("%d", &choice);
 
    switch (choice) {
    case 1:
        system("cls");
        printf("\n\n USERNAME 50 CHARACTERS MAX!!");
        printf("\n\n PASSWORD 50 CHARACTERS MAX!!");
        account();
        break;
 
    case 2:
        login();
        break;
 
    case 3:
        exit(0);
        break;
 
        getch();
    }
}
 
// Function to create accounts
// of users
void account(void)
{
    char password[20];
    int passwordlength, i, seek = 0;
    char ch;
    FILE *fp, *fu;
    struct pass u1;
    struct userpass p1;
 
    struct userpass u2;
 
    // Opening file to
    // write data of a user
    fp = fopen("username.txt", "ab");
 
    // Inputs
    system("cls");
    printf("\n\n!!!!!CREATE ACCOUNT!!!!!");
 
    printf("\n\nFIRST NAME..");
    scanf("%s", &u1.fname);
 
    printf("\n\n\nLAST NAME..");
    scanf("%s", &u1.lname);
 
    printf("\n\nFATHER's NAME..");
    scanf("%s", &u1.fathname);
 
    printf("\n\nMOTHER's NAME..");
    scanf("%s", &u1.mothname);
 
    printf("\n\nADDRESS..");
    scanf("%s", &u1.address);
 
    printf("\n\nACCOUNT TYPE");
    scanf("%s", &u1.typeaccount);
 
    printf("\n\nDATE OF BIRTH..");
    printf("\nDATE-");
    scanf("%d", &u1.date);
    printf("\nMONTH-");
    scanf("%d", &u1.month);
    printf("\nYEAR-");
    scanf("%d", &u1.year);
 
    printf("\n\nADHAR NUMBER");
    scanf("%s", u1.adharnum);
 
    printf("\n\nPHONE NUMBER");
    scanf("%s", u1.pnumber);
 
    printf("\n\nUSERNAME.. ");
    scanf("%s", &u1.username);
 
    printf("\n\nPASSWORD..");
 
    // Taking password in the form of
    // stars
    for (i = 0; i < 50; i++) {
        ch = getch();
        if (ch != 13) {
            password[i] = ch;
            ch = '*';
            printf("%c", ch);
        }
        else
            break;
    }
 
    // Writing to the file
    fwrite(&u1, sizeof(u1),
           1, fp);
 
    // Closing file
    fclose(fp);
 
    // Calling another function
    // after successful creation
    // of account
    accountcreated();
}
 
// Successful account creation
void accountcreated(void)
{
    int i;
    char ch;
    system("cls");
    printf(
        "PLEASE WAIT....\n\nYOUR DATA IS PROCESSING....");
    for (i = 0; i < 200000000; i++) {
        i++;
        i--;
    }
 
    gotoxy(30, 10);
 
    printf("ACCOUNT CREATED SUCCESSFULLY....");
    gotoxy(0, 20);
 
    printf("Press enter to login");
 
    getch();
    login();
}
 
// Login function to check
// the username of the user
void login(void)
{
    system("cls");
 
    char username[50];
    char password[50];
 
    int i, j, k;
    char ch;
    FILE *fp, *fu;
    struct pass u1;
    struct userpass u2;
 
    // Opening file of
    // user data
    fp = fopen("username.txt",
               "rb");
 
    if (fp == NULL) {
        printf("ERROR IN OPENING FILE");
    }
    gotoxy(34, 2);
    printf(" ACCOUNT LOGIN ");
    gotoxy(7, 5);
    printf("***********************************************"
           "********************************");
 
    gotoxy(35, 10);
    printf("==== LOG IN ====");
 
    // Take input
    gotoxy(35, 12);
    printf("USERNAME.. ");
    scanf("%s", &username);
 
    gotoxy(35, 14);
    printf("PASSWORD..");
 
    // Input the password
    for (i = 0; i < 50; i++) {
        ch = getch();
        if (ch != 13) {
            password[i] = ch;
            ch = '*';
            printf("%c", ch);
        }
 
        else
            break;
    }
 
    // Checking if username
    // exists in the file or not
    while (fread(&u1, sizeof(u1),
                 1, fp)) {
        if (strcmp(username,
                   u1.username)
            == 0) {
            loginsu();
            display(username);
        }
    }
 
    // Closing the file
    fclose(fp);
}
 
// Redirect after
// successful login
void loginsu(void)
{
    int i;
    FILE* fp;
    struct pass u1;
    system("cls");
    printf("Fetching account details.....\n");
    for (i = 0; i < 20000; i++) {
        i++;
        i--;
    }
 
    gotoxy(30, 10);
    printf("LOGIN SUCCESSFUL....");
    gotoxy(0, 20);
    printf("Press enter to continue");
 
    getch();
}
 
// Display function to show the
// data of the user on screen
void display(char username1[])
{
    system("cls");
    FILE* fp;
    int choice, i;
    fp = fopen("username.txt", "rb");
    struct pass u1;
 
    if (fp == NULL) {
        printf("error in opening file");
    }
 
    while (fread(&u1, sizeof(u1),
                 1, fp)) {
        if (strcmp(username1,
                   u1.username)
            == 0) {
            gotoxy(30, 1);
            printf("WELCOME, %s %s",
                   u1.fname, u1.lname);
            gotoxy(28, 2);
            printf("..........................");
            gotoxy(55, 6);
            printf("==== YOUR ACCOUNT INFO ====");
            gotoxy(55, 8);
            printf("***************************");
            gotoxy(55, 10);
            printf("NAME..%s %s", u1.fname,
                   u1.lname);
 
            gotoxy(55, 12);
            printf("FATHER's NAME..%s %s",
                   u1.fathname,
                   u1.lname);
 
            gotoxy(55, 14);
            printf("MOTHER's NAME..%s",
                   u1.mothname);
 
            gotoxy(55, 16);
            printf("ADHAR CARD NUMBER..%s",
                   u1.adharnum);
 
            gotoxy(55, 18);
            printf("MOBILE NUMBER..%s",
                   u1.pnumber);
 
            gotoxy(55, 20);
            printf("DATE OF BIRTH.. %d-%d-%d",
                   u1.date, u1.month, u1.year);
 
            gotoxy(55, 22);
            printf("ADDRESS..%s", u1.address);
 
            gotoxy(55, 24);
            printf("ACCOUNT TYPE..%s",
                   u1.typeaccount);
        }
    }
 
    fclose(fp);
 
    gotoxy(0, 6);
 
    // Menu to perform different
    // actions by user
    printf(" HOME ");
    gotoxy(0, 7);
    printf("******");
    gotoxy(0, 9);
    printf(" 1....CHECK BALANCE");
    gotoxy(0, 11);
    printf(" 2....TRANSFER MONEY");
    gotoxy(0, 13);
    printf(" 3....LOG OUT\n\n");
    gotoxy(0, 15);
    printf(" 4....EXIT\n\n");
 
    printf(" ENTER YOUR CHOICES..");
    scanf("%d", &choice);
 
    switch (choice) {
    case 1:
        checkbalance(username1);
        break;
 
    case 2:
        transfermoney();
        break;
 
    case 3:
        logout();
        login();
        break;
 
    case 4:
        exit(0);
        break;
    }
}
 
// Function to transfer
// money from one user to
// another
void transfermoney(void)
{
    int i, j;
    FILE *fm, *fp;
    struct pass u1;
    struct money m1;
    char usernamet[20];
    char usernamep[20];
    system("cls");
 
    // Opening file in read mode to
    // read user's username
    fp = fopen("username.txt", "rb");
 
    // Creating a another file
    // to write amount along with
    // username to which amount
    // is going to be transferred
    fm = fopen("mon.txt", "ab");
 
    gotoxy(33, 4);
    printf("---- TRANSFER MONEY ----");
    gotoxy(33, 5);
    printf("========================");
 
    gotoxy(33, 11);
    printf("FROM (your username).. ");
    scanf("%s", &usernamet);
 
    gotoxy(33, 13);
    printf(" TO (username of person)..");
    scanf("%s", &usernamep);
 
    // Checking for username if it
    // is present in file or not
    while (fread(&u1, sizeof(u1),
                 1, fp))
 
    {
        if (strcmp(usernamep,
                   u1.username)
            == 0) {
            strcpy(m1.usernameto,
                   u1.username);
            strcpy(m1.userpersonfrom,
                   usernamet);
        }
    }
    gotoxy(33, 16);
 
    // Taking amount input
    printf("ENTER THE AMOUNT TO BE TRANSFERRED..");
    scanf("%d", &m1.money1);
 
    // Writing to the file
    fwrite(&m1, sizeof(m1),
           1, fm);
 
    gotoxy(0, 26);
    printf(
        "--------------------------------------------------"
        "--------------------------------------------");
 
    gotoxy(0, 28);
    printf(
        "--------------------------------------------------"
        "--------------------------------------------");
 
    gotoxy(0, 29);
    printf("transferring amount, Please wait..");
 
    gotoxy(10, 27);
    for (i = 0; i < 70; i++) {
        for (j = 0; j < 1200000; j++) {
            j++;
            j--;
        }
        printf("*");
    }
 
    gotoxy(33, 40);
    printf("AMOUNT SUCCESSFULLY TRANSFERRED....");
    getch();
 
    // Close the files
    fclose(fp);
    fclose(fm);
 
    // Function to return
    // to the home screen
    display(usernamet);
}
 
// Function to check balance
// in users account
void checkbalance(char username2[])
{
    system("cls");
    FILE* fm;
    struct money m1;
    char ch;
    int i = 1, summoney = 0;
 
    // Opening amount file record
    fm = fopen("mon.txt", "rb");
 
    int k = 5, l = 10;
    int m = 30, n = 10;
    int u = 60, v = 10;
 
    gotoxy(30, 2);
    printf("==== BALANCE DASHBOARD ====");
    gotoxy(30, 3);
    printf("***************************");
    gotoxy(k, l);
    printf("S no.");
    gotoxy(m, n);
    printf("TRANSACTION ID");
    gotoxy(u, v);
    printf("AMOUNT");
 
    // Reading username to
    // fetch the correct record
    while (fread(&m1, sizeof(m1),
                 1, fm)) {
        if (strcmp(username2,
                   m1.usernameto)
            == 0) {
            gotoxy(k, ++l);
            printf("%d", i);
            i++;
            gotoxy(m, ++n);
            printf("%s", m1.userpersonfrom);
 
            gotoxy(u, ++v);
            printf("%d", m1.money1);
            // Adding and
            // finding total money
            summoney = summoney + m1.money1;
        }
    }
 
    gotoxy(80, 10);
    printf("TOTAL AMOUNT");
 
    gotoxy(80, 12);
    printf("%d", summoney);
 
    getch();
 
    // Closing file after
    // reading it
    fclose(fm);
    display(username2);
}
 
// Logout function to bring
// user to the login screen
void logout(void)
{
    int i, j;
    system("cls");
    printf("please wait, logging out");
 
    for (i = 0; i < 10; i++) {
        for (j = 0; j < 25000000; j++) {
            i++;
            i--;
        }
        printf(".");
    }
 
    gotoxy(30, 10);
    printf("Sign out successfully..\n");
 
    gotoxy(0, 20);
    printf("press any key to continue..");
 
    getch();
}
                

            
Employee Management System


                // C++ program for the above approach
#include 
 
#define max 20
using namespace std;
 
// Structure of Employee
struct employee {
    string name;
    long int code;
    string designation;
    int exp;
    int age;
};
 
int num;
void showMenu();
 
// Array of Employees to store the
// data in the form of the Structure
// of the Array
employee emp[max], tempemp[max],
    sortemp[max], sortemp1[max];
 
// Function to build the given datatype
void build()
{
    cout << "Build The Table\n";
    cout << "Maximum Entries can be "
         << max << "\n";
 
    cout << "Enter the number of "
         << "Entries required";
    cin >> num;
 
    if (num > 20) {
        cout << "Maximum number of "
             << "Entries are 20\n";
        num = 20;
    }
    cout << "Enter the following data:\n";
 
    for (int i = 0; i < num; i++) {
        cout << "Name ";
        cin >> emp[i].name;
 
        cout << "Employee ID ";
        cin >> emp[i].code;
 
        cout << "Designation ";
        cin >> emp[i].designation;
 
        cout << "Experience ";
        cin >> emp[i].exp;
 
        cout << "Age ";
        cin >> emp[i].age;
    }
 
    showMenu();
}
 
// Function to insert the data into
// given data type
void insert()
{
    if (num < max) {
        int i = num;
        num++;
 
        cout << "Enter the information "
             << "of the Employee\n";
        cout << "Name ";
        cin >> emp[i].name;
 
        cout << "Employee ID ";
        cin >> emp[i].code;
 
        cout << "Designation ";
        cin >> emp[i].designation;
 
        cout << "Experience ";
        cin >> emp[i].exp;
 
        cout << "Age ";
        cin >> emp[i].age;
    }
    else {
        cout << "Employee Table Full\n";
    }
 
    showMenu();
}
 
// Function to delete record at index i
void deleteIndex(int i)
{
    for (int j = i; j < num - 1; j++) {
        emp[j].name = emp[j + 1].name;
        emp[j].code = emp[j + 1].code;
        emp[j].designation
            = emp[j + 1].designation;
        emp[j].exp = emp[j + 1].exp;
        emp[j].age = emp[j + 1].age;
    }
    return;
}
 
// Function to delete record
void deleteRecord()
{
    cout << "Enter the Employee ID "
         << "to Delete Record";
 
    int code;
 
    cin >> code;
    for (int i = 0; i < num; i++) {
        if (emp[i].code == code) {
            deleteIndex(i);
            num--;
            break;
        }
    }
    showMenu();
}
 
void searchRecord()
{
    cout << "Enter the Employee"
         << " ID to Search Record";
 
    int code;
    cin >> code;
 
    for (int i = 0; i < num; i++) {
 
        // If the data is found
        if (emp[i].code == code) {
            cout << "Name "
                 << emp[i].name << "\n";
 
            cout << "Employee ID "
                 << emp[i].code << "\n";
 
            cout << "Designation "
                 << emp[i].designation << "\n";
 
            cout << "Experience "
                 << emp[i].exp << "\n";
 
            cout << "Age "
                 << emp[i].age << "\n";
            break;
        }
    }
 
    showMenu();
}
 
// Function to show menu
void showMenu()
{
 
    cout << "-------------------------"
         << "GeeksforGeeks Employee"
         << " Management System"
         << "-------------------------\n\n";
 
    cout << "Available Options:\n\n";
    cout << "Build Table         (1)\n";
    cout << "Insert New Entry    (2)\n";
    cout << "Delete Entry        (3)\n";
    cout << "Search a Record     (4)\n";
    cout << "Exit                (5)\n";
 
    int option;
 
    // Input Options
    cin >> option;
 
    // Call function on the basis of the
    // above option
    if (option == 1) {
        build();
    }
    else if (option == 2) {
        insert();
    }
    else if (option == 3) {
        deleteRecord();
    }
    else if (option == 4) {
        searchRecord();
    }
    else if (option == 5) {
        return;
    }
    else {
        cout << "Expected Options"
             << " are 1/2/3/4/5";
        showMenu();
    }
}
 
// Driver Code
int main()
{
 
    showMenu();
    return 0;
}
                

            
Cricket Score Board

                #include
                    #include
                    
                    struct batsman
                     {
                       char name[25];
                       int runs,score,balls,toruns,tobal,ones,twos,threes,fours,sixes;
                       int max_six,max_run,max_four;
                       float str;
                    
                     }pl1[100],pl3;
                    
                    
                    struct bowler
                     {
                       char name[25];
                       int runsgv,wkttkn,overs;
                       int max_w;
                       float econ;
                     }pl2[100],pl4;
                    
                    
                    int main()
                    {
                     int plno,choice;
                      int i,n,m;
                      printf("Enter the Batsman detail:\n");
                      printf("Enter the number of batsman:\n");
                      scanf("%d",&m);
                      for(i=0;i
password_strength.js

                

            
Employee Management System



                // C++ program for the above approach
#include 
 
#define max 20
using namespace std;
 
// Structure of Employee
struct employee {
    string name;
    long int code;
    string designation;
    int exp;
    int age;
};
 
int num;
void showMenu();
 
// Array of Employees to store the
// data in the form of the Structure
// of the Array
employee emp[max], tempemp[max],
    sortemp[max], sortemp1[max];
 
// Function to build the given datatype
void build()
{
    cout << "Build The Table\n";
    cout << "Maximum Entries can be "
         << max << "\n";
 
    cout << "Enter the number of "
         << "Entries required";
    cin >> num;
 
    if (num > 20) {
        cout << "Maximum number of "
             << "Entries are 20\n";
        num = 20;
    }
    cout << "Enter the following data:\n";
 
    for (int i = 0; i < num; i++) {
        cout << "Name ";
        cin >> emp[i].name;
 
        cout << "Employee ID ";
        cin >> emp[i].code;
 
        cout << "Designation ";
        cin >> emp[i].designation;
 
        cout << "Experience ";
        cin >> emp[i].exp;
 
        cout << "Age ";
        cin >> emp[i].age;
    }
 
    showMenu();
}
 
// Function to insert the data into
// given data type
void insert()
{
    if (num < max) {
        int i = num;
        num++;
 
        cout << "Enter the information "
             << "of the Employee\n";
        cout << "Name ";
        cin >> emp[i].name;
 
        cout << "Employee ID ";
        cin >> emp[i].code;
 
        cout << "Designation ";
        cin >> emp[i].designation;
 
        cout << "Experience ";
        cin >> emp[i].exp;
 
        cout << "Age ";
        cin >> emp[i].age;
    }
    else {
        cout << "Employee Table Full\n";
    }
 
    showMenu();
}
 
// Function to delete record at index i
void deleteIndex(int i)
{
    for (int j = i; j < num - 1; j++) {
        emp[j].name = emp[j + 1].name;
        emp[j].code = emp[j + 1].code;
        emp[j].designation
            = emp[j + 1].designation;
        emp[j].exp = emp[j + 1].exp;
        emp[j].age = emp[j + 1].age;
    }
    return;
}
 
// Function to delete record
void deleteRecord()
{
    cout << "Enter the Employee ID "
         << "to Delete Record";
 
    int code;
 
    cin >> code;
    for (int i = 0; i < num; i++) {
        if (emp[i].code == code) {
            deleteIndex(i);
            num--;
            break;
        }
    }
    showMenu();
}
 
void searchRecord()
{
    cout << "Enter the Employee"
         << " ID to Search Record";
 
    int code;
    cin >> code;
 
    for (int i = 0; i < num; i++) {
 
        // If the data is found
        if (emp[i].code == code) {
            cout << "Name "
                 << emp[i].name << "\n";
 
            cout << "Employee ID "
                 << emp[i].code << "\n";
 
            cout << "Designation "
                 << emp[i].designation << "\n";
 
            cout << "Experience "
                 << emp[i].exp << "\n";
 
            cout << "Age "
                 << emp[i].age << "\n";
            break;
        }
    }
 
    showMenu();
}
 
// Function to show menu
void showMenu()
{
 
    cout << "-------------------------"
         << "GeeksforGeeks Employee"
         << " Management System"
         << "-------------------------\n\n";
 
    cout << "Available Options:\n\n";
    cout << "Build Table         (1)\n";
    cout << "Insert New Entry    (2)\n";
    cout << "Delete Entry        (3)\n";
    cout << "Search a Record     (4)\n";
    cout << "Exit                (5)\n";
 
    int option;
 
    // Input Options
    cin >> option;
 
    // Call function on the basis of the
    // above option
    if (option == 1) {
        build();
    }
    else if (option == 2) {
        insert();
    }
    else if (option == 3) {
        deleteRecord();
    }
    else if (option == 4) {
        searchRecord();
    }
    else if (option == 5) {
        return;
    }
    else {
        cout << "Expected Options"
             << " are 1/2/3/4/5";
        showMenu();
    }
}
 
// Driver Code
int main()
{
 
    showMenu();
    return 0;
}
                

            
Bus Reservation System


                // C Program to implement Bus Reservation System
#include 
#include 
#include 

// Define a structure to store bus information
struct Bus{
    int busNumber;
    char source[50];
    char destination[50];
    int totalSeats;
    int availableSeats;
    float fare;
};

// Define a structure to store user login information
struct User{
    char username[50];
    char password[50];
};

// Function to display the main menu
void displayMainMenu(){
    printf("\n=== Main Menu ===\n");
    printf("1. Login\n");
    printf("2. Exit\n");
    printf("Enter your choice: ");
}

// Function to display the user menu
void displayUserMenu(){
    printf("\n=== User Menu ===\n");
    printf("1. Book a Ticket\n");
    printf("2. Cancel a Ticket\n");
    printf("3. Check Bus Status\n");
    printf("4. Logout\n");
    printf("Enter your choice: ");
}

// Function to perform user login
int loginUser(struct User users[], int numUsers, char username[], char password[]){
    for (int i = 0; i < numUsers; i++){
        if (strcmp(users[i].username, username) == 0 && strcmp(users[i].password, password) == 0){
            return i; // Return the index of the logged-in user
        }
    }
    return -1; // Return -1 if login fails
}

// Function to book tickets
void bookTicket(struct Bus buses[], int numBuses){
    printf("\nEnter Bus Number: ");
    int busNumber;
    scanf("%d", &busNumber);

    // Find the bus with the given busNumber
    int busIndex = -1;
    for (int i = 0; i < numBuses; i++){
        if (buses[i].busNumber == busNumber){
            busIndex = i;
            break;
        }
    }

    if (busIndex == -1){
        printf("Bus with Bus Number %d not found.\n", busNumber);
    }
    else{
        printf("Enter Number of Seats: ");
        int seatsToBook;
        scanf("%d", &seatsToBook);

        if (buses[busIndex].availableSeats < seatsToBook){
            printf("Sorry, only %d seats are available.\n", buses[busIndex].availableSeats);
        }
        else{
            buses[busIndex].availableSeats -= seatsToBook;
            printf("Booking successful! %d seats booked on Bus Number %d.\n", seatsToBook, busNumber);
        }
    }
}

// Function to cancel tickets
void cancelTicket(struct Bus buses[], int numBuses){
    printf("\nEnter Bus Number: ");
    int busNumber;
    scanf("%d", &busNumber);

    // Find the bus with the given busNumber
    int busIndex = -1;
    for (int i = 0; i < numBuses; i++){
        if (buses[i].busNumber == busNumber){
            busIndex = i;
            break;
        }
    }

    if (busIndex == -1){
        printf("Bus with Bus Number %d not found.\n", busNumber);
    }
    else{
        printf("Enter Number of Seats to Cancel: ");
        int seatsToCancel;
        scanf("%d", &seatsToCancel);

        if (seatsToCancel > (buses[busIndex].totalSeats - buses[busIndex].availableSeats)){
            printf("Error: You can't cancel more seats than were booked.\n");
        }
        else{
            buses[busIndex].availableSeats += seatsToCancel;
            printf("Cancellation successful! %d seats canceled on Bus Number %d.\n", seatsToCancel,
                   busNumber);
        }
    }
}

// Function to check bus status
void checkBusStatus(struct Bus buses[], int numBuses){
    printf("\nEnter Bus Number: ");
    int busNumber;
    scanf("%d", &busNumber);

    // Find the bus with the given busNumber
    int busIndex = -1;
    for (int i = 0; i < numBuses; i++){
        if (buses[i].busNumber == busNumber){
            busIndex = i;
            break;
        }
    }

    if (busIndex != -1){
        printf("\nBus Number: %d\n", buses[busIndex].busNumber);
        printf("Source: %s\n", buses[busIndex].source);
        printf("Destination: %s\n", buses[busIndex].destination);
        printf("Total Seats: %d\n", buses[busIndex].totalSeats);
        printf("Available Seats: %d\n", buses[busIndex].availableSeats);
        printf("Fare: %.2f\n", buses[busIndex].fare);
    }
    else{
        printf("Bus with Bus Number %d not found.\n", busNumber);
    }
}

int main(){
    // Initialize user data
    struct User users[5] = {
        {"user1", "pass1"}, {"user2", "pass2"}, {"user3", "pass3"}, {"user4", "pass4"}, {"user5", "pass5"},
    };
    int numUsers = 5;

    // Initialize bus data
    struct Bus buses[3] = {
        {101, "City A", "City B", 50, 50, 500.0},
        {102, "City C", "City D", 40, 40, 400.0},
        {103, "City E", "City F", 30, 30, 300.0},
    };
    int numBuses = 3;

    int loggedInUserId = -1; // Index of the logged-in user

    while (1){
        if (loggedInUserId == -1){
            displayMainMenu();
            int choice;
            scanf("%d", &choice);

            if (choice == 1){
                char username[50];
                char password[50];

                printf("Enter Username: ");
                scanf("%s", username);
                printf("Enter Password: ");
                scanf("%s", password);

                loggedInUserId = loginUser(users, numUsers, username, password);
                if (loggedInUserId == -1){
                    printf("Login failed. Please check your username and password.\n");
                }
                else{
                    printf("Login successful. Welcome, %s!\n", username);
                }
            }
            else if (choice == 2){
                printf("Exiting the program.\n");
                break;
            }
            else{
                printf("Invalid choice. Please try again.\n");
            }
        }
        else{
            displayUserMenu();
            int userChoice;
            scanf("%d", &userChoice);

            switch (userChoice){
            case 1:
                bookTicket(buses, numBuses);
                break;
            case 2:
                cancelTicket(buses, numBuses);
                break;
            case 3:
                checkBusStatus(buses, numBuses);
                break;
            case 4:
                printf("Logging out.\n");
                loggedInUserId = -1;
                break;
            default:
                printf("Invalid choice. Please try again.\n");
            }
        }
    }

    return 0;
}
                

            
Quiz Game

                // C program to implement a simple quiz game
#include 
#include 
#include 
#include 

// max number of questions defined as macro
#define MAX_QUESTIONS 5

// Structure to store question details
typedef struct {
    char question[256];
    char options[4][64];
    int correct_option;
} Question;

// function to display question to the user
void displayQuestion(Question q)
{
    printf("%s\n", q.question);
    for (int i = 0; i < 4; i++) {
        printf("%d. %s\n", i + 1, q.options[i]);
    }
}

// function to check the answer
int checkAnswer(Question q, int user_answer)
{
    return (user_answer == q.correct_option);
}

// driver code
int main()
{

    // random number generator
    srand(time(NULL));

    // Initializing questions, options and the correct
    // answer
    Question original_questions[MAX_QUESTIONS] = {
        { "Which bird lays the largest egg?",
          { "Owl", "Ostrich", "Kingfisher", "Woodpecker" },
          2 },
        { "How many legs does a spider have?",
          { "7", "8", "6", "5" },
          2 },
        { "Where does the President of the United States "
          "live while in office?",
          { "The White House", "The Parliament",
            "House of Commons", "Washington DC" },
          1 },
        { "Which state is famous for Hollywood?",
          { "Sydney", "California", "New York", "Paris" },
          2 },
        { "What is a group of lions called?",
          { "Drift", "Pride", "Flock", "Drove" },
          2 }
    };

    // Array of struct data-type
    Question questions[MAX_QUESTIONS];
    memcpy(questions, original_questions,
           sizeof(original_questions));

    int num_questions = MAX_QUESTIONS;

    int score = 0;

    printf("Hola! Here's your Quiz Game!\n");

    for (int i = 0; i < MAX_QUESTIONS; i++) {
        int random_index = rand() % num_questions;
        Question current_question = questions[random_index];
        displayQuestion(current_question);

        int user_answer;
        printf("Enter your answer (1-4): ");
        scanf("%d", &user_answer);

        if (user_answer >= 1 && user_answer <= 4) {
            if (checkAnswer(current_question,
                            user_answer)) {
                printf("Correct!\n");
                score++;
            }
            else {
                printf("Incorrect. The correct answer is "
                       "%d. %s\n",
                       current_question.correct_option,
                       current_question.options
                           [current_question.correct_option
                            - 1]);
            }
        }
        else {
            printf("Invalid choice. Please enter a number "
                   "between 1 and 4.\n");
        }

        questions[random_index]
            = questions[num_questions - 1];
        num_questions--;
    }

    printf("Well Done Champ !!!! Quiz completed! Your "
           "score: %d/%d\n",
           score, MAX_QUESTIONS);

    return 0;
}