#include using namespace std; int main() { int n = 15; // Output cout << "Hi from C++, brought to you by the number " << n << endl; printf( "Hi from C, brought to you by the number %d, %x\n", n, n ); // Arrays int k; int a[5] = { 1, 2, 4, 8, 16 }; for( k=0; k < 5; k++ ) cout << a[k] << " "; cout << endl; // Null-terminated strings. char str1[10] = "moose"; char str2[4]; str2[0] = 'e'; str2[1] = 'l'; str2[2] = 'k'; str2[3] = '\0'; printf( "Two of my favorite ungulates are %s and %s\n", str1, str2 ); for( k=0; str1[k] != '\0'; k++ ) { } printf( "The length of the first of my favorite ungulates is %d\n", k ); cout << "But it's easier to compute that using strlen, like so: " << strlen( str1 ) << endl; printf( "Check out strlen, strcmp, strcat, strcpy, strncpy, strncat, strncmp, etc.\n" ); cout << "(By the way, you shouldn't really mix printf and cout like this.)" << endl; return 0; }