-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrc.cpp
1584 lines (1580 loc) · 29 KB
/
src.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*final version of computer science project class -12 `
by Sanjay and Shreyas.*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<iomanip.h>
#include<time.h>
#include<stdlib.h>
#include<ctype.h>
#include<constream.h>
#include<process.h>
#include<fstream.h>
#include<string.h>
#define T "Correct"
#define F "Wrong"
#define square(x) x*x
#define power3(x) x*x*x
#define power4(x) x*x*x*x
#define power5(x) x*x*x*x*x
struct player_info //structure for storing player information
{char name[20];
int age;
}PI;
int inputting_age()// age error handler:to make sure the age makes sense
{int n;
while(!(cin>>n)||n<=0||n>145)
{clrscr();
cout<<"Incorrect input.Please enter your age again."<<endl;
cin.clear();
cin.ignore();
}
return n;
}
int inputting()//number error handler: to make sure the number entered by the user make sense
{int n;
while(!(cin>>n))
{clrscr();
cout<<"Incorrect input.Please enter your answer again."<<endl;
cin.clear();
cin.ignore();
}
return n;
}
void input_details()
{cout<<"Enter your name: ";
gets(PI.name); //changed
cout<<"Enter your age: ";
PI.age=inputting_age();
}
void write_review()
{clrscr();
char A[10000];
fstream datafile;
cin.ignore();
cout<<"Write your review."<<endl;
cin.getline(A,10000);
cout<<endl;
datafile.open("reviews.txt",ios::app);
datafile<<endl;
datafile.write(PI.name,strlen(PI.name));
datafile<<":";
datafile.write(A,strlen(A));
getch();
}
void read_review()
{clrscr();
char ch='Y',A[10000];
fstream datafile;
datafile.open("reviews.txt",ios::in);
while(!datafile.eof()&&toupper(ch)=='Y')
{datafile.getline(A,10000);
for(int i=0;i<80;i++)
cout<<"*";
cout<<endl;
cout<<A<<endl;
cout<<"Do you wanna continue(y->yes/n->no)"<<endl;
cin>>ch;
while((toupper(ch)!='Y')&&(toupper(ch)!='N'))
{cout<<"Invalid entry. Please try again"<<endl;
cin>>ch;
}
}
if(datafile.eof())
{cout<<"End of reviews"<<endl;
}
getch();
}
int round_counter=0;
struct round_stack
{int value;
round_stack*next;
}*top=NULL;
round_stack*new_node(int n)
{round_stack*node;
node=new round_stack;
if(node==NULL)
cout<<"Out of memory"<<endl;
else
{node->value=n;
node->next=NULL;
}
return node;
}
void push(int n)
{round_stack *temp=NULL,*p=NULL;
temp=new_node(n);
if(top==NULL)
top=temp;
else
{p=top;
top=temp;
top->next=p;
}
}
void round_stack_display()
{int n=round_counter;
round_stack *temp=top;
cout<<"Your score for all the rounds are :"<<endl;
while(temp!=NULL&&n>0)
{cout<<"Round "<<n<<": "<<temp->value<<endl;
n--;
temp=temp->next;
}
}
class memory_game_details
{protected:
char *name;
int age;
int points;
int wronganswer;
int correctanswer;
int ans;
public:
void result()
{ cout<<"RESULT \n"
<<"NAME: "<<PI.name<<endl;
cout<<"AGE: "<<PI.age<<endl
<<"SCORE: "<<points<<endl
<<"NUMBER OF QUESTIONS WRONG : "<<wronganswer<<endl
<<"NUMBER OF QUESTIONS CORRECT : "<<correctanswer<<endl;
}
};
class memory_game_operations:public memory_game_details
{protected:
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int t;
int n;
int m[3][3];
int p[3][3];
int A[20];
int B[20];
int C[20];
int D[20];
addition(int x,int y)
{int z;
z=x+y;
return z;
}
subtraction(int x,int y)
{int z;
z=x-y;
return z;
}
multiplication(int x,int y)
{int z;
z=x*y;
return z;
}
division(int x,int y)
{int z;
z=x/y;
return z;
}
function1(int y)//for mathematical functions of type y^2+y+10
{int p=0;
p=square(y)+y+10;
return p;
}
long function2(int y)//for mathematical functions of type y^4+3*y^3+7*y^2+5*y+10
{long q=0;
q=power4(y)+3*power3(y)+7*square(y)+5*y+10;
return q;
}
generaltAP(int ,int );
generaltGP(int ,int);
factorial(int);
matrixsum(int X[][3]);
bubble_sort_asc(int[],int[]);
bubble_sort_desc(int[],int[]);
arraysum(int[],int[],int[]);
public:
memory_game_operations()
{a=0;
b=0;
c=0;
d=0;
e=0;
f=0;
g=0;
h=0;
t=0;
n=0;
}
};
class Level_1:public memory_game_operations
{public:
void rules_level_1()
{char ch;
clrscr();
cout<<"RULE:The rule of the game is that the answer you give for the question "<<endl
<<"should actually be the answer of the previous question"<<endl
<<"Example: "<<endl
<<"Q. what is 1 + 1 ?(keep the answer in you mind) "<<endl
<<"Q. what is 2 - 1? "<<endl
<<"ans. 2 (answer to the previous question)"<<endl
<<"This pattern continues for the following qustions"<<endl;
cout<<"The use of calculators or writing on paper is prohibited"<<endl;
cout<<"correct question :1 point "<<endl
<<"wrong question : -2 points "<<endl;
cout<<"Once you start playing the level you cannot exit the game"<<endl
<<"until you are done"<<endl;
cout<<"Press any key to start";
getch();
}
void question_bank1();
};
class Level_2:public memory_game_operations
{public:
void rules_level_2()
{clrscr();
cout<<"RULE:The rule of the game is that the answer you give for a question "<<endl
<<"should be the answer to the question that preceedes the previous question "<<endl
<<"Example : "<<endl
<<"Q. what is 1 + 1 ?(keep the answer in your mind) "<<endl
<<"Q. what is 2-3 ?(keep the answer in your mind)"<<endl
<<"Q. what is 2*3 ?"
<<"ans. 2 (answer of the question preceedes the question by two steps)"
<<"The pattern continues for the folowing questions "<<endl;
cout<<"The use of calculators or writing on paper is prohibited"<<endl;
cout<<"Correct answer:3 points "<<endl
<<"Wrong answer:-2 points "<<endl;
cout<<"Once you start playing the level you cannot exit the game"<<endl
<<"until you are done"<<endl;
cout<<"Press any key to start "<<endl;
getch();
}
void question_bank2();
};
class Level_3:public memory_game_operations
{public:
void rules_level_3()
{clrscr();
cout<<"RULE:The rule of the game is that answer you give for a question must be "<<endl
<<"the answer that preceedes the question by three steps. "<<endl
<<"Example: "<<endl
<<"Q. what is 1+1 ?(keep the answer in your mind) "<<endl
<<"Q. what is 2-1 ?(keep the answer in your mind) "<<endl
<<"Q. what is 4*4 ?(keep the answer in your mind) "<<endl
<<"Q. what is 3/3 ? "<<endl
<<"ans 2(answer that preceedes the question by three steps) "<<endl
<<"The pattern continues for the folowing questions "<<endl;
cout<<"The use of calculators is prohibited"<<endl
<<"Calculations can be done on paper"<<endl;
cout<<"Correct answer:5 points"<<endl
<<"wrog answer:-2 points"<<endl;
cout<<"Once you start playing the level you cannot exit the game"<<endl
<<"until you are done"<<endl;
cout<<"press any key to start "<<endl;
getch();
}
void question_bank3();
};
int memory_game_operations::arraysum(int X[5],int Y[5],int Z[5])
{int check=0;
for(int i=0;i<5;i++)
if(Z[i]!=X[i]+Y[i])
check++;
if(check==0)
return 0;
else
return 1;
}
int memory_game_operations::bubble_sort_asc(int X[5],int Y[5])
{int temp=0,check=0;
for(int i=0;i<5;i++)
for(int j=0;j<4-i;j++)
if(X[j]>X[j+1])
{temp=X[j];
X[j]=X[j+1];
X[j+1]=temp;
}
for(i=0;i<5;i++)
if(Y[i]!=X[i])
check++;
if(check==0)
return 0;
else
return 1;
}
int memory_game_operations::bubble_sort_desc(int X[5],int Y[5])
{int temp=0,check=0;
for(int i=0;i<5;i++)
for(int j=0;j<4-i;j++)
if(X[j]<X[j+1])
{temp=X[j];
X[j]=X[j+1];
X[j+1]=temp;
}
for(i=0;i<5;i++)
if(Y[i]!=X[i])
check++;
if(check==0)
return 0;
else
return 1;
}
int memory_game_operations::generaltAP(int x,int y)
{int z;
z=x+(y-1)*x;
return z;
}
int memory_game_operations::generaltGP(int x,int y)
{int z=1;
for(int i=0;i<y;i++)
z=z*x;
return z;
}
int memory_game_operations::factorial(int x)
{int z=1;
for(int i=1;i<=x;i++)
z=z*i;
return z;
}
int memory_game_operations::matrixsum(int x[][3])
{int a=0;
for(int i=0;i<3;i++)
a+=x[i][i];
return a;
}
void Level_1::question_bank1()
{char ch;
round_counter=0;
do{clrscr();
points=0;
correctanswer=0;
wronganswer=0;
srand(time(0));
a=(rand()%10)+1;
b=(rand()%10)+1;
cout<<"1.What is "<<a<<"+"<<b<<". \n";
getch();
clrscr();
c=(rand()%10)+1;
d=(rand()%10)+1;
cout<<"2.What is "<<c<<"-"<<d<<". \n";
ans=inputting();
if(ans==addition(a,b))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++ ;
}
getch();
clrscr();
a=(rand()%10)+1;
b=(rand()%10)+1;
cout<<"3.What is "<<a<<"x"<<b<<"\n";
ans=inputting();
if(ans==subtraction(c,d))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"4.What is 4/2 ? \n";
ans=inputting();
if(ans==multiplication(a,b))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%5)+1;
cout<<"5.What is"<<a<<"! ?\n";
ans=inputting();
if(ans==2)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
c=(rand()%20)+10;
d=(rand()%20)+10;
cout<<"6.What is "<<c<<"x"<<d<<"?\n";
ans=inputting();
if(ans==factorial(a))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"7.What is 48/16? \n";
ans=inputting();
if(ans==multiplication(c,d))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%10)+1;
cout<<"8.What is ("<<a<<")^2 ?\n";
ans=inputting();
if(ans==3)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"9.What is the Square root of 16?\n";
ans=inputting();
if(ans==square(a))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"10. What is tan(45)(if 45 is in degree measure)? \n";
ans=inputting();
if(ans==4)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%50)+20;
b=(rand()%50)+30;
cout<<"11. What is"<<a<<"+"<<b<<"?\n";
ans=inputting();
if(ans==1)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"12. Whatis the 10th term in the sequece 2,4,6,8,... ?\n";
ans=inputting();
if(ans==addition(a,b))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"13.What is the sum of the first diagonal of the given matrix ?\n";
for(int i=0;i<3;i++)
{for(int j=0;j<3;j++)
{m[i][j]=(rand()%9)+1;
cout<<m[i][j]<<" ";
}
cout<<"\n";
}
ans=inputting();
if(ans==20)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%20)+15;
b=(rand()%10)+5;
cout<<"14. What is the value of "<<a<<"x"<<b<<"?\n";
ans=inputting();
if(ans==matrixsum(m))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
c=(rand()%50)+40 ;
d=(rand()%160)+50;
cout<<"15. What is the value of "<<c<<"+"<<d<<"?\n";
ans=inputting();
if(ans==multiplication(a,b))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"16. What is the value of 144/24?\n";
ans=inputting();
if(ans==addition(c,d))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%10)+1;
cout<<"17. What is the value of f(x)=x^2+x+10 if x="<<a<<"?\n";
ans=inputting();
if(ans==6)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
c=(rand()%100)+40;
d=(rand()%150)+70;
cout<<"18. What is the value of "<<c<<"-"<<d<<"? \n";
ans=inputting();
if(ans==function1(a))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"19. What is the value of ln(e) ?\n";
ans=inputting();
if(ans==subtraction(c,d))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%10)+2;
cout<<"20. What is the value of f(x)=x^4+3x^3+7x^2+5x+10? if x="<<a<<"?\n";
ans=inputting();
if(ans==1)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"21. What is sum of the corresponding elements of the following two arrays"<<endl;
cout<<"A: ";
for(i=0;i<5;i++)
{b=(rand()%10)+1;
A[i]=a;
cout<<A[i]<<"\t";
}
cout<<endl<<"B: ";
for(i=0;i<5;i++)
{b=(rand()%10)+1;
B[i]=b;
cout<<B[i]<<"\t";
}
cout<<endl;
ans=inputting();
if(ans==function2(a))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"22. Arrange the following elements in ascending order"<<endl<<"D: ";
for(i=0;i<5;i++)
{a=(rand()%10)+1;
D[i]=a;
cout<<D[i]<<"\t";
}
cout<<endl;
for(i=0;i<5;i++)
C[i]=inputting();
if(arraysum(A,B,C)==0)
/*functions returns a zero value if elements of C is equal to the sum
of the elements of A and B*/
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"23. Arrange the following elements in descending order"<<endl<<"A: ";
for(i=0;i<5;i++)
{a=(rand()%10)+1;
A[i]=a;
cout<<A[i]<<"\t";
}
cout<<endl;
for(i=0;i<5;i++)
C[i]=inputting();
if(bubble_sort_asc(D,C)==0)//it will return 0 if it is in ascending order
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%10)+1;
b=(rand()%10)+1;
cout<<"24. What is the result of the operation "<<a<<" + "<<b<<endl;
for(i=0;i<5;i++)
B[i]=inputting();
if(bubble_sort_desc(A,B)==0)
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
c=(rand()%20)+1;
d=(rand()%20)+1;
cout<<"25. What is the result of the operation "<<c<<" * "<<d<<endl;
ans=inputting();
if(ans==addition(a,b))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"26. What is the answer of the 25th question"<<endl;
ans=inputting();
if(ans==multiplication(c,d))
{cout<<T;
points++;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
result();
round_counter++;
getch();
clrscr();
push(points);
round_stack_display();
getch();
cout<<"Do you wanna play level-1 again ?(y->yes/n->no)"<<endl;
cin>>ch;
while((toupper(ch)!='Y')&&(toupper(ch)!='N'))
{cout<<"Invalid entry. Please try again"<<endl;
cin>>ch;
}
}while(toupper(ch)=='Y');
}
void Level_2::question_bank2()
{char ch;
round_counter=0;
do{clrscr();
points=0;
correctanswer=0;
wronganswer=0;
srand(time(0));
a=(rand()%5)+0;
b=(rand()%5)+0;
cout<<"1.What is the value of "<<a<<"+"<<b<<"?\n";
getch();
clrscr();
c=(rand()%15)+2;
d=(rand()%5)+2;
cout<<"2.What is the value of"<<c<<"x"<<d<<"?\n";
getch();
clrscr();
e=(rand()%50)+20;
f=(rand()%50)+20;
cout<<"3. What is the value of"<<e<<"-"<<f<<"?\n";
ans=inputting();//needs to be the answer of the first question
if(ans==addition(a,b))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"4. What is the value of 625/25 ?\n";
ans=inputting();//needs to be the answer of the second question
if(ans==multiplication(c,d))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%10)+1;
cout<<"5. What is the value of ("<<a<<")^3 ?\n";
ans=inputting();//needs to be the answer of the third question
if(ans==subtraction(e,f))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"6.What is the value of tan45 (Whhere 45 is the angle in degrees) ? \n";
ans=inputting();//needs to be the answer of the fourth question
if(ans==25)
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
c=(rand()%5)+1;
cout<<"7. What is the coeffient of x in the expansion of (x+"<<c<<")^2 ?\n";
ans=inputting();//needs to be the answer of the fifth question
if(ans==power3(a))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
e=(rand()%5)+2;
cout<<"8.What is the fifth term is the G.P: "<<e<<","<<e*e<<","<<e*e*e<<"... ?\n";
ans=inputting();//needs to be the answer of the sixth question
if(ans==1)
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%100)+90;
b=(rand()%100)+90;
cout<<"9. What is the value of "<<a<<"x"<<b<<"?\n";
ans=inputting();//needs to be the answer of the seventh question
if(ans==2*c)
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"10. What is the value of sin(90) (if 90 is the angle in degrees) ?\n";
ans=inputting();//needs to be the answer of the eighth question
if(ans==power5(e))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
c=(rand()%200)+100;
d=(rand()%300)+100;
cout<<"11. What is the value of"<<c<<"-"<<d<<"?\n";
ans=inputting();//needs to be the answer of the 9th question
if(ans==multiplication(a,b))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
e=(rand()%9)+1;
cout<<"12. What is the value of f(x)=x^2+x+10 if x="<<e<<"?\n";
ans=inputting();//needs to be the answer of the tenth question
if(ans==1)
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"13. What is the value 168/12?\n";
ans=inputting();//needs to be the answer of the 11th question
if(ans==subtraction(c,d))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
cout<<"14. What is the sum of the diagonal of the following matrix ?\n";
for(int i=0;i<3;i++)
{for(int j=0;j<3;j++)
{m[i][j]=(rand()%9)+1;
cout<<m[i][j]<<" ";
}
cout<<"\n";
}
ans=inputting();//needs to be the answer of the 12th question
if(ans==function1(e))
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;
points-=2;
wronganswer++;
}
getch();
clrscr();
a=(rand()%10)+5;
b=(rand()%10)+5;
cout<<"15. What is the value of "<<a<<"x"<<b<<"?\n";
ans=inputting();//needs to be the answer of the 13th question
if(ans==14)
{cout<<T;
points+=3;
correctanswer++;
}
else
{cout<<F;