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();
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!"));
function convertTemperature(value, unit) {
if (unit === "C") {
return (value * 9/5) + 32;
} else if (unit === "F") {
return (value - 32) * 5/9;
} else {
return "Invalid unit";
}
}
console.log(convertTemperature(100, "C"));
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()
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()
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)
Welcome to GeeksforGeeks TechCon 2025
The Ultimate Technology and Programming Conference
About |
Schedule |
Speakers |
Contact
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
Name:
Email:
Message:
Send
#include
#include
struct Customer {
char name[50];
char phoneNumber[15];
float usage;
float totalBill;
};
struct Customer
customers[100];
int customerCount = 0;
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");
}
}
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);
}
}
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");
}
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");
}
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");
}
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;
}
#include
#include
#include
#include
#include
#define HEIGHT 20
#define WIDTH 40
int snakeTailX[100], snakeTailY[100];
int snakeTailLen;
int gameover, key, score;
int x, y, fruitx, fruity;
void setup() {
gameover = 0;
x = WIDTH / 2;
y = HEIGHT / 2;
fruitx = rand() % WIDTH;
fruity = rand() % HEIGHT;
while (fruitx == 0)
fruitx = rand() % WIDTH;
while (fruity == 0)
fruity = rand() % HEIGHT;
score = 0;
}
void draw() {
system("cls");
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++) {
if (j == 0 || j == WIDTH)
printf("#");
if (i == y && j == x)
printf("O");
else if (i == fruity && j == fruitx)
printf("*");
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");
}
for (int i = 0; i < WIDTH + 2; i++)
printf("-");
printf("\n");
printf("score = %d", score);
printf("\n");
printf("Press W, A, S, D for movement.\n");
printf("Press X to quit the game.");
}
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;
}
}
}
void logic() {
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;
}
switch (key) {
case 1:
x--;
break;
case 2:
x++;
break;
case 3:
y--;
break;
case 4:
y++;
break;
default:
break;
}
if (x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT)
gameover = 1;
for (int i = 0; i < snakeTailLen; i++) {
if (snakeTailX[i] == x && snakeTailY[i] == y)
gameover = 1;
}
if (x == fruitx && y == fruity) {
fruitx = rand() % WIDTH;
fruity = rand() % HEIGHT;
while (fruitx == 0)
fruitx = rand() % WIDTH;
while (fruity == 0)
fruity = rand() % HEIGHT;
score += 10;
snakeTailLen++;
}
}
void main() {
setup();
while (!gameover) {
draw();
input();
logic();
Sleep(33);
}
}
#include
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;
}
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";
break;
}
return month;
}
int numberOfDays(int monthNumber, int year)
{
if (monthNumber == 0)
return (31);
if (monthNumber == 1) {
if (year % 400 == 0
|| (year % 4 == 0
&& year % 100 != 0))
return (29);
else
return (28);
}
if (monthNumber == 2)
return (31);
if (monthNumber == 3)
return (30);
if (monthNumber == 4)
return (31);
if (monthNumber == 5)
return (30);
if (monthNumber == 6)
return (31);
if (monthNumber == 7)
return (31);
if (monthNumber == 8)
return (30);
if (monthNumber == 9)
return (31);
if (monthNumber == 10)
return (30);
if (monthNumber == 11)
return (31);
}
void printCalendar(int year)
{
printf(" Calendar - %d\n\n", year);
int days;
int current = dayNumber(1, 1, year);
for (int i = 0; i < 12; i++) {
days = numberOfDays(i, year);
printf("\n ------------%s-------------\n",
getMonthName(i));
printf(" Sun Mon Tue Wed Thu Fri Sat\n");
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;
}
int main()
{
int year = 2016;
printCalendar(year);
return 0;
}
#include
#include
#include
#include
#include
#include
#define MAX_WORD_LENGTH 50
#define MAX_TRIES 6
struct WordWithHint {
char word[MAX_WORD_LENGTH];
char hint[MAX_WORD_LENGTH];
};
void displayWord(const char word[], const bool guessed[]);
void drawHangman(int tries);
int main()
{
srand(time(NULL));
struct WordWithHint wordList[] = {
{ "geeksforgeeks", "Computer coding" },
{ "elephant", "A large mammal with a trunk" },
{ "pizza", "A popular Italian dish" },
{ "beach", "Sandy shore by the sea" },
};
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]);
}
}
#include
#include
int main() {
char op;
double a, b, res;
printf("Enter an operator (+, -, *, /): ");
scanf("%c", &op);
printf("Enter two operands: ");
scanf("%lf %lf", &a, &b);
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 to implement Snake and Ladder Game
#include
#include
#include
int rollDie() { return rand() % 6 + 1; }
int player1 = 0, player2 = 0;
void printBoard()
{
int board[101];
for (int i = 1; i <= 100; i++) {
board[i] = i;
}
int alt = 0;
int iterLR = 101;
int iterRL = 80;
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");
}
int movePlayer(int currentPlayer, int roll)
{
int newPosition = currentPlayer + roll;
int snakesAndLadders[101];
for (int i = 0; i <= 100; i++) {
snakesAndLadders[i] = 0;
}
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;
}
return newSquare;
}
int main()
{
srand(time(0));
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();
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;
}
}
currentPlayer = (currentPlayer == 1) ? 2 : 1;
}
return 0;
}
#include
#include
#include
#include
#include
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);
void gotoxy(int x, int y)
{
COORD c;
c.X = x;
c.Y = y;
SetConsoleCursorPosition(
GetStdHandle(STD_OUTPUT_HANDLE), c);
}
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];
};
struct money {
char usernameto[50];
char userpersonfrom[50];
long int money1;
};
struct userpass {
char password[50];
};
int main()
{
int i, a, b, choice;
int passwordlength;
gotoxy(20, 3);
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();
}
}
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;
fp = fopen("username.txt", "ab");
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..");
for (i = 0; i < 50; i++) {
ch = getch();
if (ch != 13) {
password[i] = ch;
ch = '*';
printf("%c", ch);
}
else
break;
}
fwrite(&u1, sizeof(u1),
1, fp);
fclose(fp);
accountcreated();
}
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();
}
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;
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 ====");
gotoxy(35, 12);
printf("USERNAME.. ");
scanf("%s", &username);
gotoxy(35, 14);
printf("PASSWORD..");
for (i = 0; i < 50; i++) {
ch = getch();
if (ch != 13) {
password[i] = ch;
ch = '*';
printf("%c", ch);
}
else
break;
}
while (fread(&u1, sizeof(u1),
1, fp)) {
if (strcmp(username,
u1.username)
== 0) {
loginsu();
display(username);
}
}
fclose(fp);
}
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();
}
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);
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;
}
}
void transfermoney(void)
{
int i, j;
FILE *fm, *fp;
struct pass u1;
struct money m1;
char usernamet[20];
char usernamep[20];
system("cls");
fp = fopen("username.txt", "rb");
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);
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);
printf("ENTER THE AMOUNT TO BE TRANSFERRED..");
scanf("%d", &m1.money1);
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();
fclose(fp);
fclose(fm);
display(usernamet);
}
void checkbalance(char username2[])
{
system("cls");
FILE* fm;
struct money m1;
char ch;
int i = 1, summoney = 0;
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");
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);
summoney = summoney + m1.money1;
}
}
gotoxy(80, 10);
printf("TOTAL AMOUNT");
gotoxy(80, 12);
printf("%d", summoney);
getch();
fclose(fm);
display(username2);
}
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();
}
#include
#define max 20
using namespace std;
struct employee {
string name;
long int code;
string designation;
int exp;
int age;
};
int num;
void showMenu();
employee emp[max], tempemp[max],
sortemp[max], sortemp1[max];
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();
}
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();
}
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;
}
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 (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();
}
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;
cin >> 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();
}
}
int main()
{
showMenu();
return 0;
}
#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
#include
#define max 20
using namespace std;
struct employee {
string name;
long int code;
string designation;
int exp;
int age;
};
int num;
void showMenu();
employee emp[max], tempemp[max],
sortemp[max], sortemp1[max];
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();
}
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();
}
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;
}
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 (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();
}
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;
cin >> 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();
}
}
int main()
{
showMenu();
return 0;
}
Bus Reservation System
#include
#include
#include
struct Bus{
int busNumber;
char source[50];
char destination[50];
int totalSeats;
int availableSeats;
float fare;
};
struct User{
char username[50];
char password[50];
};
void displayMainMenu(){
printf("\n=== Main Menu ===\n");
printf("1. Login\n");
printf("2. Exit\n");
printf("Enter your choice: ");
}
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: ");
}
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 -1;
}
void bookTicket(struct Bus buses[], int numBuses){
printf("\nEnter Bus Number: ");
int busNumber;
scanf("%d", &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);
}
}
}
void cancelTicket(struct Bus buses[], int numBuses){
printf("\nEnter Bus Number: ");
int busNumber;
scanf("%d", &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);
}
}
}
void checkBusStatus(struct Bus buses[], int numBuses){
printf("\nEnter Bus Number: ");
int busNumber;
scanf("%d", &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(){
struct User users[5] = {
{"user1", "pass1"}, {"user2", "pass2"}, {"user3", "pass3"}, {"user4", "pass4"}, {"user5", "pass5"},
};
int numUsers = 5;
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;
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
#include
#include
#include
#include
#define MAX_QUESTIONS 5
typedef struct {
char question[256];
char options[4][64];
int correct_option;
} Question;
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]);
}
}
int checkAnswer(Question q, int user_answer)
{
return (user_answer == q.correct_option);
}
int main()
{
srand(time(NULL));
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 }
};
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;
}