KBC Game in C# Language
Program includes
Loading screen
Password screen
Otp screen
KBC Game Code
Source Code:
#include<conio.h>#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<dos.h>
void pass();
void otp();
void load();
void load2();
void load2() //Loading Function
{
int i;
clrscr();
textcolor(11);
gotoxy(20,10);
printf("Loading.....\n");
// cout<<"Loading\n";
for(i=1;i<=80;i++)
{
textcolor(RED);
cprintf("|");
}
for(i=1;i<=80;i++)
{
gotoxy(i,11);
textcolor(WHITE);
delay(50);
cprintf("|");
}
textcolor(10);
cprintf("Loading Completed....");
textcolor(7);
getch();
}
void load() //Another Loading Function
{
int i;
clrscr();
for(i=1;i<=100;i++)
{ delay(100);
gotoxy(32,12);
textcolor(1);
cprintf("Loading..........%d% ",i);
}
printf("\n\n\t\tCompleted");
textcolor(5);
cprintf("\n WElCOME TO THE PROGRAM.......");
getch();
}
void otp() //OTP Funtion
{
int size=5;
char code[5],ch,otp[5];
int n=0;
randomize();
clrscr();
while(n<size)
{ ch=(char)random(127);
if(ch>='a'&&ch<='z'||ch>'0'&&ch<='9'||ch>='A'&&ch<='Z')
{ code[n++]=ch;
}
} code[n]='\0';
textcolor(8);
cprintf("\n\nCAPTCHA CODE GENERATED....\n");
textcolor(9);
cprintf( code);
printf("\n");
textcolor(6);
cprintf("\n\nEnter The OTP to Verify:");
textcolor(7);
scanf("%s",otp);
if(strcmp(code,otp)==0)
{ textcolor(5);
cprintf("\n\n OTP Verified.......");
}
else
printf("\n\n\tOTP wrong...!!!!");
getch();
exit (0);
}
void pass() //Password Function
{
char pwd[]="Mr.Perfect",verify[20],ch;
int i=0;
clrscr();
textcolor(6);
cprintf("\n\nEnter The Password To Verify:");
textcolor(7);
do
{
ch=getch();
if(ch!=13)
{ verify[i++]=ch;
printf("*");
}
else
{ verify[i++]='\0';
}
}while(ch!=13);
if(strcmp(pwd,verify)==0)
{ textcolor(9);
printf("\n\nPassword Matched....");
textcolor(7);
}
else
printf("\nWrong Password ...");
exit (0);
getch();
}
void question1();
void main()
{
clrscr();
otp();
load2();
pass();
load();
clrscr();
printf("\n\n\n\n\n\n\t\t\t\t ______________\n\n\t\t\t\t | Hello And WELCOME TO\t|\n\t\t\t\t | KAUN BANEGA\t\t|\n\t\t\t\t | CROREPATI\t\t|\n\t\t\t\t |______________\t|\n");
getch();
question1();
getch();
}
char a,b,c,d,A,B,C,D,ans;
void question2();
void question1()
{
clrscr();
fflush(stdin);
printf("\nQ1.What does AC and DC stand for in the electrical field?");
printf("\n A. A Rock Band from Australia\n B. Alternating Current and Direct Current");
printf("\n C. Average Current and Discharged Capacitor\n D. Atlantic City and District of Columbia\n\t\t ");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'C':
case 'c':
case 'D':
case 'd':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'B':
case 'b':
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.1,000!!");
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'B' || ans == 'b')
{
getche();
clrscr();
question2();
}
}
void question3();
void question2()
{
clrscr();
fflush(stdin);
printf("\nQ2. Which Function reallocates memory?");
printf("\nA. talloc \t B. calloc");
printf("\nC. malloc \t D.realloc\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'C':
case 'c':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'D':
case 'd':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.2,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'D' || ans == 'd')
{
getche();
clrscr();
question3();
}
}
void question4();
void question3()
{
clrscr();
fflush(stdin);
printf("Q3.Who is the author of Hamlet?");
printf("\nA. Christopher Marlowe\t B. William Shakespeare");
printf("\nC. Geoffrey Chaucer \t D. Edith Wharton\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'C':
case 'c':
case 'D':
case 'd':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'B':
case 'b':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.3,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'B' || ans == 'b')
{
getche();
clrscr();
question4();
}
}
void question5();
void question4()
{
clrscr();
fflush(stdin);
printf("Q4.Which Header file is essential for use of sacnf() function?");
printf("\nA. pco.h \t B. conio.h");
printf("\nC. string.h \t D.stdio.h\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'C':
case 'c':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'D':
case 'd':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.5,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'D' || ans == 'd')
{
getche();
clrscr();
question5();
}
}
void question6();
void question5()
{
clrscr();
fflush(stdin);
printf("Q5.Which of the following function is used to find occurrence of a given string in another string?");
printf("\nA. strchr() \t B. strrchr()");
printf("\nC. strstr() \t D. strnset()\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'D':
case 'd':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'C':
case 'c':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.10,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'c' || ans == 'C')
{
getche();
clrscr();
question6();
}
}
void question7();
void question6()
{
clrscr();
fflush(stdin);
printf("Q6.Which command is used to skip the rest of the loop and carry on from the top of the loop again?");
printf("\nA. break \t B. resume");
printf("\nC. continue \t D. skip\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'D':
case 'd':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'C':
case 'c':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.25,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!"); +
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'C' || ans == 'c')
{
getche();
clrscr();
question7();
}
}
void question8();
void question7()
{
clrscr();
fflush(stdin);
printf("Q7.Compact discs, (according to the original CD specifications)hold how many minutes of music?");
printf("\nA. 74 mins\t B. 56 mins");
printf("\nC. 60 mins\t D. 90 mins\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'B':
case 'b':
case 'C':
case 'c':
case 'D':
case 'd':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'A':
case 'a':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.50,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'A' || ans == 'a')
{
getche();
clrscr();
question8();
}
}
void question9();
void question8()
{
clrscr();
fflush(stdin);
printf("Q8.Standard ANSI C recognizes _____ numbers of keywords?");
printf("\n A. 11 \t B. 45");
printf("\n C. 25 \t D. 32\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'C':
case 'c':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'D':
case 'd':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.1,00,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'D' || ans == 'd')
{
getche();
clrscr();
question9();
}
}
void question10();
void question9()
{
clrscr();
fflush(stdin);
printf("Q9.When functions calls itselfs,it is known as _____.");
printf("\nA. call \t B. Again");
printf("\nC. repeat \t D. Recursion\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'C':
case 'c':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'D':
case 'd':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.10,00,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'D' || ans == 'd')
{
getche();
clrscr();
question10();
}
}
void question11();
void question10()
{
clrscr();
fflush(stdin);
printf("\n\nQ10.Sishu is the literary work of which Indian author?");
printf("\nA. Jawaharlal Nehru");
printf("\nB. Arundhati Roy");
printf("\nC. Rabindranath Tagore");
printf("\nD. Vikram Seth \n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'D':
case 'd':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'C':
case 'c':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.50,00,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'C' || ans == 'c')
{
getche();
clrscr();
question11();
}
}
void question11()
{
clrscr();
fflush(stdin);
printf("\n\nQ11.What was the active medium used in the first working laser ever constructed?");
printf("\nA. Helium-neon gas");
printf("\nB. A ruby rod");
printf("\nC. A diamond block ");
printf("\nD. Carbon dioxide gas\n\t\t");
scanf("%c",&ans);
switch(ans)
{
case 'A':
case 'a':
case 'C':
case 'c':
case 'D':
case 'd':
printf("\n\nWRONG ANSWER!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
break;
case 'B':
case 'b':
{
printf("\n\nCORRECT ANSWER!!");
printf("\n\nYOU WON Rs.1,00,00,000!!");
}
break;
default:
printf("\n\nIMPROPER CHOICE!!");
printf(" \n\n\t\t Thanks For Playing !!\n\n");
printf(" Made By BHAVESH POPTANI");
}
if(ans == 'B' || ans == 'b')
{
getche();
clrscr();
gotoxy(30,8);
textcolor(4);
printf("CONGRATULATIONS!!\n" );
textcolor(6);
printf(" \n\n\t\t Thanks You !!\n\n");
textcolor(5);
printf(" Made By BHAVESH POPTANI");
}
}
can give me a code of kbc game in c++ ????
ReplyDeleteafter clicking otp the game not working
ReplyDelete