|
What
follows are Mr. Walt's samples to run and modify on
the compiler at: http://www.tutorialspoint.com/compile_cpp_online.php
// Sample #1 Hello
World.
#include <iostream>
using namespace
std;
int main()
{
cout
<< "Hello World" << endl;
return
0;
}
// Sample #2.
Adding numbers.
#include <stdio.h>
#include <iostream>
using namespace
std;
int main ()
{
/* variable
definition: */
int a, b,
c;
cout <<
"Please enter an integer to add: ";
cin >>
a;
cout <<
"Please enter a second integer to add: ";
cin >>
b;
c = a + b;
printf("Total
= %d \n", c);
return
0;
}
//Sample #3. Loops.
#include <stdio.h>
int loop;
int main ()
{
for(loop=1;loop<=12;
loop++)
{
printf("This
loop will run 12 times.\n");
}
return
0;
}
Web site contents © Copyright Walt Noon 2015, All rights reserved.
|