i have this huge book called "teach yourself C++" and i posted a sample code on this other forums of a C programmer. and he told me i was typing C! ?????????? C!?!?!?!?!?! i want to learn C++, tell me if this is wrong:
Code:
#include <iostream>
#include <stdlib.h>
// callin the fuctions
int menu();
int calc();
int calcadd();
int calcsub();
int calcmult();
int calcdiv();
/* here is the main deal, the design and the goto the menu function
thingy, you know */
int main()
{
// wicked ViperVision design!
cout << "### ### ### ###" << endl;
cout << " ### ### ### ###" << endl;
cout << " ### ### ### ###" << endl;
cout << " ### ### ### ###" << endl;
cout << " ### ### ### ###" << endl;
cout << " ### ### ### ###" << endl;
cout << " ### ### ### ###" << endl;
cout << " ###### ######" << endl;
cout << " #### iper #### ision v0.5" << endl << endl;
cout << " Console Based Computer Utensile Program " << endl << endl;
// end the wicked design :(
system("pause");
menu();
}
/* notice how my main is really short? cuz it dont need too much here!
here is our main menu function */
int menu()
{
int selut;
cout << "please select a utility to use! " << endl << "(0 = Quit, 1 = QuickCalc)" << endl;
cin >> selut;
if (selut == 1) {
cout << "you chose to use the calculater" << endl;
calc();
} else if (selut == 0) {
cout << "you chose to quit, c'ya!" << endl;
system("pause");
return 0;
}
}
int calc()
{
int calcwhat;
cout << "what do you plan to do?" << endl << "(1 = Add, 2 = Subtract, 3 = Multiply, 4 = Divide, 5 = back)" << endl;
cin >> calcwhat;
if (calcwhat == 1) {
calcadd();
} else if (calcwhat == 2) {
calcsub();
} else if (calcwhat == 3) {
calcmult();
} else if (calcwhat == 4) {
calcdiv();
} else if (calcwhat == 5) {
menu();
} else {
cout << "you typed something strange, redo" << endl;
calc();
}
}
int calcadd()
{
int addone;
int addtwo;
int product;
cout << "the first number: ";
cin >> addone;
cout << endl;
cout << "the second number: ";
cin >> addtwo;
cout << endl;
product = addone + addtwo;
system("pause");
cout << addone << " + " << addtwo << " = " << product << endl;
system("pause");
calc();
}
int calcsub()
{
int subone;
int subtwo;
int product;
cout << "the first number: ";
cin >> subone;
cout << endl;
cout << "the second number: ";
cin >> subtwo;
cout << endl;
product = subone - subtwo;
system("pause");
cout << subone << " - " << subtwo << " = " << product << endl;
system("pause");
calc();
}
int calcmult()
{
int mulone;
int multwo;
int product;
cout << "the first number: ";
cin >> mulone;
cout << endl;
cout << "the second number: ";
cin >> multwo;
cout << endl;
product = mulone * multwo;
system("pause");
cout << mulone << " * " << multwo << " = " << product << endl;
system("pause");
calc();
}
int calcdiv()
{
int divone;
int divtwo;
int product;
cout << "the first number: ";
cin >> divone;
cout << endl;
cout << "the second number: ";
cin >> divtwo;
cout << endl;
product = divone / divtwo;
system("pause");
cout << divone << " / " << divtwo << " = " << product << endl;
system("pause");
calc();
}
this DOS program compiles and works.
is this C or C++? cuz i dont know if my book is teaching me C++ or C, and C# i dont want to learn at all.