Week 5
Week 5
Header file
#include <iostream>
using namespace std;
Main Function
int main()
{ Function Body
cout<<“First Program.”<<endl;
return 0;
Print Statement
}
Writing Program using Dev C++
Create a Project (File> new>Project
Write Project name and select Console application & C++ Project
Select the location to save (create new folder to save in)
A C++ source file will be created, you can use it or create own file
Write the Code and save
Goto Execute > Compile or Press F9
Correct the errors if any
Goto Execute > Run or Press F10
Or Compile & Run by Pressing F11
Quick Questions about Print Statement
Anything written inside double quotes will appear as-it-is on screen
cout is object defined in iostream
<< is stream insertion operator
endl put the insertion pointer at new line
You can combine multiple strings / expressions using << operator
What will be displayed?
cout<<“2+3”<<endl<<“is 5”;
cout<<“2+3 is”<<5;
cout<<“2+3”<<“is”<<2+3;
Formatting the Output