Using cout

Cout is a function as like as printf. We use cout in c++ and printf in C. Cout is easy to use. 

1: #include <iostream.h>
 
• 2: int main()
 
• 3: { cout << "Hello there.\n";
 
• 4: cout << "Here is 5: " << 5 << "\n";
 
• 5: cout << "The manipulator endl writes a new line to the screen." <<endl;
 
• 6: cout << "Here is a very big number:\t" << 70000 << endl;
 
• 7: cout << "Here is the sum of 8 and 5:\t" << 8+5 << endl;
 
• 8: cout << "Here's a fraction:\t\t" << (float) 5/8 << endl;
 
• 9: cout << "And a very very big number:\t" << (double) 7000 * 7000 << endl;
 
• 10: cout << "Don't forget to replace Jesse Liberty with your name...\n";
 
• 11: return 0;}

Output using cout: 

Hello there.
 
•Here is 5: 5
 
• The manipulator endl writes a new line to the screen.
 
• Here is a very big number: 70000
 
• Here is the sum of 8 and 5: 13
 
• Here's a fraction: 0.625
 
• And a very very big number: 4.9e+07
 
• Don't forget to replace Jesse Liberty with your name...
 • Jesse Liberty is a C++ programmer! 

No comments:

Post a Comment

free counters