0
How do you declare a string, variable, and integer in both C# and C++ ?
as a beginner it's the hardest move to get started
1 Answer
+ 1
Strings and integers _are_ variables because they're not. They're data types (what kind of info they can hold) of variables. Much like a Ford and a Chevy are both vehicles. You can have a vehicle that's a Chevy, but you can't have a Chevy that's a Ford. If that makes sense.
int -- would declare an integer (a whole number)
char -- would declare a single character 1 byte in size (i.e. 'A')
char[n] -- would declare a string with a max of n characters (whatever number you choose).
float -- would be a single-precision floating point number
double -- would be a double-precision floating point number
The reason there are multiple data types is for you to optimize the program. Why allocate processing power to get the two-hundred-thousandth round of a number when a simple integer will do?
Hope that helps!