First question is, if I did go off to code what would be the true advent AI (artificial intelligence), well, I without the A, would I choose the project "Console Application"?
Next question, I made all of the code below and learned everything in that code only in exactly 2 days time, and didn't know any of it yesterday, am I doing better than most?
// #include "stdafx.h" // uncomment if using visual studio
#include <iostream>
int getUserInput()
{
std::cout << "Please enter an integer: ";
int value;
std::cin >> value;
return value;
}
int getMathematicalOperation()
{
std::cout << "Please enter which operator you want (1 = +, 2 = -, 3 = *, 4 = /): ";
int op;
std::cin >> op;
// What if the user enters an invalid character?
// We'll ignore this possibility for now
return op;
}
int calculateResult(int x, int op, int y)
{
// note: we use the == operator to compare two values to see if they are equal
// we need to use if statements here because there's no direct way to convert op into the appropriate operator
if (op == 1) // if user chose addition (#1)
return x + y; // execute this line
if (op == 2) // if user chose subtraction (#2)
return x - y; // execute this line
if (op == 3) // if user chose multiplication (#3)
return x * y; // execute this line
if (op == 4) // if user chose division (#4)
return x / y; // execute this line
return -1; // default "error" value in case user passed in an invalid op
// note: This isn't a good way to handle errors, since -1 could be returned as a legitimate value
}
void printResult(int result)
{
std::cout << "Your result is: " << result << std::endl;
}
int main()
{
// Get first number from user
int input1 = getUserInput();
// Get mathematical operation from user
int op = getMathematicalOperation();
// Get second number from user
int input2 = getUserInput();
// Calculate result and store in temporary variable (for readability/debug-ability)
int result = calculateResult(input1, op, input2 );
// Print result
printResult(result);
}
I did not understood the first question but I did understood the second one so I'm gonna answer it.
If you learned all this stuff in just 2 days then you are doing great and yes I think you learned faster than most of new comers would learn in just 2 days, it all gets down to your motivation, curiosity and imagination.
Keep going you just learned the very basics of c++ , you will see the languages true potential when you will learn about while and for loops, recursivity, classes, templates etc
I'll say a couple things to make my first question clearer. Are Console Applications a do-all project? If I want to make artificial intelligence should it be a Console Application? I'm using the CodeBlocks Compiler. It asks yiu to pick a project type to open and then do ya coding in~
If you want to use the Console, then you create a Console application, it's that simple. If you're making a game using SFML or SDL for example, most likely you don't need the console.
So it depends on what kind of AI program you're gonna work on.
While my AI is simple, and short code needed, it may need the most advanced techniques/symbols to implement it into the code, so should I code it in a Console Application or other project-type?
While my AI is simple, and short code needed, it may need the most advanced techniques/symbols to implement it into the code, so should I code it in a Console Application or other project-type?
There are no limitations to the "techniques/symbols" used to "implement it into the code" present in one project type that is not also present in another. This is a non-issue.
So then why must I choose a project type before creating the page to type my code into?
There is no "must." You're perfectly free to write code without creating a project. Likewise, your code isn't tied to the type of project that uses it. If you want to use a console (and I imagine you do) then use a console application. If you decide you want to change the type of the project later... change the project type later.
"I don't know, maybe you're over enthusiastic about coding and try it three times?"
What do you mean by your first line? It didn't make sense. Make sure to make all of it clearer.
"i saw your codes is about functions.."
.....so?... ???
While my AI is simple, and short code needed, it may need the most advanced techniques/symbols to implement it into the code, so should I code it in a Console Application or other project-type?
You can consider putting the AI code into a static library or into a DLL.
Other projects that might want to reuse the AI code would simply need to include header files only.
whichever method you choose, (lib or dll) just instruct your linker to link against prebuilt AI library. (import lib for dll or static lib for lib)