mathematical porgram
Author |
Message |
nik88
|
Posted: Tue Oct 18, 2005 4:54 pm Post subject: mathematical porgram |
|
|
ive written this program in turbo C++ but when i try to run it in Visual Studio it says that i have a fatal error: C1083. here is my program
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
short i, ctr;
short score=0;
short num1, num1, ans;
void add() {
cout << "\n";
randomize ();
num1 = (rand () % 100) + 1;
num2 = (rand () % 100) + 1;
do {
cout << num1 << " + " << num2 << " = ";
cin >> ans;
ctr++;
}while ((ans!=(num1+num2)) && ctr<3);
switch (ctr) {
case 1 : cout << "correct! \n\n"; score += 10; break;
case 2 : cout << "correct! \n\n"; score += 5; break;
case 3 : cout << "correct! \n\n"; score += 2; break;
default : cout << "wrong! the answer was " << num1+num2 << "\n\n";break;
}
}
void subt() {
cout << "\n";
randomize ();
num1 = (rand () % 100) + 1;
num2 = (rand () % 100) + 1;
do {
cout <<num1 << " - " << num2 << "=";
cin >> ans;
ctr++;
}while ((ans!= (num1-num2)) && ctr<3);
switch (ctr) {
case 1 : cout << "correct! \n\n"; score += 10; break;
case 2 : cout << "correct! \n\n"; score += 5; break;
case 3 : cout << "correct! \n\n"; score += 2; break;
default : cout << "wrong! the answer was " << num1-num2 << "\n\n";break;
}
}
void mult() {
cout << "\n";
randomize ();
num1 = (rand () % 100) + 1;
num2 = (rand () % 100) + 1;
do {
cout <<num1 << " * " << num2 << "=";
cin >> ans;
ctr++;
}while ((ans!= (num1*num2)) && ctr<3);
switch (ctr) {
case 1 : cout << "correct! \n\n"; score += 10; break;
case 2 : cout << "correct! \n\n"; score += 5; break;
case 3 : cout << "correct! \n\n"; score += 2; break;
default : cout << "wrong! the answer was " << num1*num2 << "\n\n";break;
}
}
void main () {
char choice;
do {
cout << "Please choose one of the following. (score: "<< score <<")";
cout << "0. exit, 1. add, 2. sub, 3. mult";
choice = getch()
ctr = 0;
switch (choice) {
case '1': add (); break;
case '2': subt (); break;
case '3': mult(); break;
}
}while (choice!= '0');
} |
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Tue Oct 18, 2005 6:31 pm Post subject: (No subject) |
|
|
This is the Visual BASIC, not Visual Studio in general section.
What version do you have? VC++ probably doesn't have conio.h (which is Turbo-C specific), and it works differently too. If you don't know these things, or the differences, etc, then you shouldn't be doing it. |
|
|
|
|
|
|
|