Basics of A Typical C++ Environment
Basics of A Typical C++ Environment
Environment
Program is created in the editor and
Editor Disk stored on disk
Disk
Primary memory
CPU CPU takes each instruction and executes
. it, possibly storing new data values
as the program executes
Introduction to C++ programming
A simple program: printing a line of Text
int main ()
{
std::cout<<“welcome to c++!\n”; // this is a statement
Return 0; //indicates that program ended successfully
}
Std::cout
– cout=name
– Std=namespace
We should insert std before every
occurrence of cout-cin tedious
int main ()
{
Int integer1, integer2, sum; //declarations
std::cout<<“Enter first integer\n”; // prompt
std::cin >>integer1; // read an integer
std::cout<<“Enter second integer\n”; // prompt
std ::cin >>integer2; //read an integer
sum = integer1 + integer2; //assignment of sum
std::cout <<“Sum is “sum <<std::endl; //print sum
Return 0; //indicates that program ended successfully
}
Int integer1, integer2, sum;
– Multiple declarations
– Or each declaration alone
Int integers
– Char y =3;
– Char sum =x + y;
C++ identifiers:
– Any series of characters (letters, digits, underscores) not starting
with a digit.
Memory
integer1 45
integer2 72
sum 117