View Full Version : a question about integers

06-14-2009, 11:27 PM
ok, im really begining at c++. i know int means integer.so when i was writing a basic code liek this:

#include <iostream>
using namespace std;

int main ()
int a, b, c;
int result;

a= 9;
b= 12;
c= 459;
a= a + b + 2 * c -a * b;
result= a * b + 6;

cout << result;

return 0;

ok, <iostream> is blue because i was wondering, what exactly does that do in this code.

i made int main(); red because i thought integers were supposed to be used somewhere in the code again like the int. a, b, and c, and result. what does main() do?

06-14-2009, 11:43 PM
A function is a block of code.
It has been put together so that you can make use of it without re-writing the whole thing wherever you need that functionality.
So, you can call that block (called function) any number of times.

main() is one such function and it is the starting point of your C code. This function will be called by the startup routine which will reside in one of the libraries that gets compiled with your C code.

Hope it helps,

06-14-2009, 11:47 PM
ok, thank you. i think i get it a little now.

06-15-2009, 06:15 AM
The #include <iostream> line means to include a system file called iostream. The #include is called an include directive. It does much as the name implies, it tells the compiler to include a file at that line. The iostream file has a grouping of functions that give you basic input/output functionality.

If you see a include directive like this: #include "somefile.h" where there are quotes instead of angles, it means the file is a user file and it uses the path specified instead of searching the system include paths.

Does that make sense?

06-15-2009, 04:05 PM
yea. thanx