Let's do an example;
- Open your text editor i.e., notepad and type the following code;
#include <iostream>
#include <string>
using namespace std;
int main(){
string n ("User");
cout << "Enter your name: ";
getline(cin, n);
cout << "\nWelcome to C++ programming, " << n << "!\n" << endl;
return 0;}
#include <string>
using namespace std;
int main(){
string n ("User");
cout << "Enter your name: ";
getline(cin, n);
cout << "\nWelcome to C++ programming, " << n << "!\n" << endl;
return 0;}
2. Save this file as Hello.cpp or Hello.cc on your desktop (Note: It should not have any other extension).
3. Go to your shell or command prompt and change directory to desktop, e.g.,
cd C:\Users\RAWG\Desktop
4. Type the following;
c++ Hello.cpp {to compile c++}
5. An executable will be created on your desktop "a.exe".
6. On your command prompt or shell type the file's name "a" i.e., a.exe.
7. It should ask for your name then display "Welcome to C++ programming, <name>!".
8. Do the same process for a C executable save it as "Hello.c".
Here is the code for a C executable;
#include <stdio.h>
int main(void )
{
printf("Welcome to C programming!\n" );
return 0;}
9. On any other platform go to your shell and use your OS editor follow the instructions as above.