so here is the code
// This is a simple c++ program
// Just playing around with my variables
// Practice your c++ code son!
# include <iostream>
# include <string>
using namespace std;
# define NEWLINE '\n'
# define PI 3.14159
int main ()
{
// first we declare variables, assigning a type to each
int a, b;
double result;
double circum;
double rc;
// next, we show what is each variable
a = 2;
b = 3;
result = (a + b)*2;
circum = PI * result;
// next, we have to assign another process for 'rc' caclcuation
// now we assign a value with b values and then re-create the value again
a = b;
b = 4;
rc = a + b * a;
// now, let us completeit, we will echo the results
cout << result;
cout << NEWLINE;
cout << circum;
cout << NEWLINE;
cout << rc;
cout << NEWLINE;
cin.get(); // asks for a pasue
// let's end the program now. if everything works out, it will show in console
return 0;
}
Constants
i always have problems with the concepts of constants, even when i learned about php....
let say in the code above, if i assign result and circum as double
how can i see the difference if i assign them with int instead?
in what cases, will i see the difference, and in what condition, will i use these constant?
thanks for any reply any help


Sign In
Create Account


Back to top










