Printing in C++.
C++ print command.
Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Wednesday July 30th, 2008 11:46 PM
// use g++ main.cpp to compile.
/*
iostream is input output stream: this is to talk to the console
*/
#include <iostream>
// you must make a function called main in every c++ program
using namespace std;
int main() {
int number = 7;
int add;
add = 6;
int some = number + add;
// c way to print
printf("\n\n");
printf("%d + %d = %d\n",number,add,some);
printf("\tHello World\n");
printf("My Name is Dan, this is my first c program\n\n");
// c++ way to print
// c++ endl is same as \n
// this one specifies the std namespace in the code
std::cout << " This is the C++ way to print stuff to the screen." << std::endl;
// this one doesnt need std because we imported the namespace std.
cout << " This is the C++ way to print stuff to the screen." << endl;
cout << number << " + " << add << " = " << some << endl << endl;
return 0;
}
Downloads:
Download: print.cpp 913 B
Please login or Click Here to register for downloads
Print by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com
