Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {
- printf("1. Play game?\n");
- printf("2. Exit.\n");
- int x,p=0;
- int ara[6];
- scanf("%d", &x);
- if(x==2)
- {
- return 0;
- }
- else if(x==1)
- {
- int i;
- srand(time(0));
- for(i=0; i<6; i++)
- {
- ara[i]=rand()%100;
- }
- printf("First pair of numbers: ");
- for(i=0; i<2; i++)
- {
- printf(" %d ",ara[i]);
- }
- printf("\nPress any key to proceed to the next pair...");
- getch();
- printf("\nSecond pair of numbers: ");
- for(i=2; i<4; i++)
- {
- printf(" %d ",ara[i]);
- }
- printf("\nPress any key to proceed to the next pair...");
- getch();
- printf("\nThird pair of numbers: ");
- for(i=4; i<6; i++)
- {
- printf(" %d ",ara[i]);
- }
- printf("\nPress any key to proceed to the questions...");
- for(p=0; p<3; p++)
- {
- printf("\nWhat were the first numbers? 18 90 34 %d 990 %d", ara[1], ara[0]);
- printf("\nAnswer: ");
- int a,b;
- scanf("%d %d",&a,&b);
- p=0;
- if((a==ara[0]|| a==ara[1])&&(b==ara[0]|| b==ara[1]))
- {
- printf("\nCorrect!!!");
- p++;
- }
- else
- {
- printf("\nWrong Answer! Start from the first question!");
- p=0;
- }
- if(p==1)
- {
- printf("\nWhat were the second numbers? 28 39 %d 43 70 %d", ara[3], ara[2]);
- printf("\nAnswer: ");
- int c,d;
- scanf("%d %d",&c,&d);
- if((c==ara[2]|| c==ara[3])&&(d==ara[3]|| d==ara[2]))
- {
- p++;
- printf("\nCorrect!!!");
- }
- else
- {
- printf("\nWrong Answer! Start from the first question!");
- p=0;
- }
- }
- if(p==2)
- {
- printf("\nWhat were the third numbers? 68 79 %d 34 19 %d", ara[4], ara[5]);
- printf("\nAnswer: ");
- int e,f;
- scanf("%d %d",&e,&f);
- if((e==ara[4]|| e==ara[5])&&(f==ara[4]|| f==ara[5]))
- {
- p++;
- printf("\nCorrect!!!");
- }
- else
- {
- printf("\nWrong Answer! Start from the first question!");
- p=0;
- }
- }
- }
- printf("\nCongratulations! You won! Want to play again?");
- printf("\n1. Play Game?");
- printf("\n2. Exit");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement