Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need some coding for a c++.
Its a Maths test program. It is meant to composes
a maths test consisting of 10 addition,
subtraction or multiplication problems.
(operands in the range 0-12).
The user must answer all 10 problems correctly.Please send me some code

here is some code that I did in one programming class I had long ago try it must work,, I did not compile but it should work and good luck in your class
/////////////// Park University
#include
#include
#include
#include
#includeusing namespace std;
main()
{
int coran = 0;
int count = 1;
int incoran =0;
char response;
string z;{
void inst();
cout > z;
cout > response;
}
switch (response)
{
case 'a' :
void add();
{int a,b,c,ans,count,incoran,coran;
srand (time (NULL));
coran = 0;
count = 1;
incoran =0;
while (count> ans;
c=b+a;if (c==ans)
{
cout > ans;
c=b*
a;if (c==ans)
{
cout > ans;
c=a-b;if (c==ans)
{
cout > ans;
c=b/a;if (c==ans)
{
cout << "GREAT" << endl;
cout << "Your answer is correct" << endl;
cout << "\n" << endl;
++ coran;
++ count;
}
else
{
cout << "UNFORTUNATELY" << endl;
cout << "Your answer is incorrect" << endl;
cout << "Here is the correct answer" << endl;
cout << c << endl;
cout << "\n" << endl;
++ incoran;
++ count;
}}
}
break;
case 'e':
{
cout << "Good bye" << endl;
}
break;
default: cout << "ENTER A,B,C,D,E," << endl;
break;
}
void close();
{
cout << "CONGRATULATIONS" << endl;
cout << z << endl;
cout << "YOU GOT" << endl;
cout << coran << endl
;
cout << "ANSWERS CORRECT" << endl;
cout << "\n" << endl;
cout << "AND YOU GOT" << endl;
cout << incoran << endl;
cout << "ANSWERS INCORRECT" << endl;
cout << "\n" << endl;
return main();
}
}

LOL
Here is a bit of C code for you. If you can't convert it to C++ then...
[ means less than symbol
] means greater than symbol#include [stdio.h]
#define MAXNUM 4
int main(void)
{
char *testQ[MAXNUM] = { "What is 2+2: ",
"What is 2*2: ",
"What is 2-2: ",
"What is 2/2: " };
int testA[MAXNUM] = { 4, 4, 0, 1 };
int studentA[MAXNUM];
int i, j;
for(i = 0; i [ MAXNUM; i++)
{
printf("%d) %s", (i+1), testQ[i]);
scanf("%d", &studentA[i]);
}
for(j = 0; j [ MAXNUM; j++)
{
if(studentA[j] != testA[j])
{
printf("\nYou answered question %d, incorrectly.", (j+1));
printf("\nYou answered %d, but the correct answer is %d\n", studentA[j], testA[j]);
}
else
{
printf("\nYou answered question %d, correctly.", (j+1));
printf("\nThe correct answer is %d\n", testA[j]);
}
}
printf("\n\nEnd of test.");
return 0;
}HTH

![]() |
program error
|
programme error
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |