Tag Archives: Own Program

How to Start C++ Programing in Ubuntu and Your First C++ Program

To start programming in C++ for Ubuntu you will Need a C++ compiler for Ubuntu install a C++ compiler such as Code Blocks. To Install it goto the Ubuntu software center and search for and install the package Code Blocks it will look like this in the software manager interface.

Package Manager Code BlocksNow Open the Code Blocks C++ compiler from the application Menu> Programming now you can start to compile C++ programs in Ubuntu.

Create a new Project and select console application then name it this is how you create a new project in Code Blocks your Compiler may Differ.

 

The Hello World Program
#include

using namespace std;

int main()
{
cout < < “Hello world!” << endl;
return 0;
}

When the Hello World Program is ran it will output like this
Output of helloworld

Editing the Hello World Program
You can edit the Hello World Program to include more lines or other text here is an example edit of the hello world program and it’s output.

#include

using namespace std;

int main()
{
cout < < “Hello world!” << endl;
cout << “Is not helping me very much” < return 0;
}
This will output like this

Edit Hello World

Edited Hello World

A Simple First Program  for Beginners in C++
This Video although using another C++ compiler has helped me greatly in understanding more about C++. But unfortunately the Video Creators Website does not seem to be online anymore as the video is from 2006 but still relevant.So I have included the Code he is compiling in the video below. Watch the Video to understand a little better

#include

using namespace std;

int main()
{
double dnumber1 = 0.0;
double dnumber2 = 0.0;
double dnumber3 = 0.0;
double daverage = 0.0;
cout< < “Enter 3 Number” < cout<< “First Number = “; cin>> dnumber1;
cout< < “Second Number = “; cin>> dnumber2;
cout< < “Thrid Number = “;cin>> dnumber3;
daverage = (dnumber1 + dnumber2 + dnumber3) / 3;
cout< < “Average of Your 3 Numbers =” << daverage <

return 0;
}
This is the Output of the Code mentioned in the VideoCreating your Own Program from this C++ Code

I have made some edits to the original code to create a simple C++ program for working out the average daily visitors to my website. I done this by altering the code a little and including some extra input here is the code I used for my website daily visitor average program. Here is the Code and Output

// my first program in C++
#include

using namespace std;

int main(void)
{
double dnumber1 = 0.0; // asks for the first number
double dnumber2 = 0.0;
double dnumber3 = 0.0;
double dnumber4 = 0.0;
double dnumber5 = 0.0;
double dnumber6 = 0.0;
double dnumber7 = 0.0;
double daverage = 0.0;

cout< < “Enter The Amount of Visitors on Each Day” <cout<< “Monday visitors = “; cin>> dnumber1; // displays text monday
cout< < “Tuesday visitors = “; cin>> dnumber2;
cout< < “Wedensday visitors = “;cin>> dnumber3;
cout< < “Thursday visitors = “;cin>> dnumber4;
cout< < “Friday visitors = “;cin>> dnumber5;
cout< < “Saturday visitors = “;cin>> dnumber6;
cout< < “Sunday visitors = “;cin>> dnumber7;

daverage = (dnumber1 + dnumber2 + dnumber3 + dnumber4 + dnumber5 + dnumber6 + dnumber7) / 7;

cout< < “Average Daily Visitors =” << daverage <

return 0;
}


Places for C++ Programming Tutorials
The C++ Tutorial

Is a well documented C++ resource containing tutorials and command referances
C Programming and C++ Programming

 

Helps you learn about compiling C++ programs and Applications and includes a mailing list

Other Resources for Learning C++ as a Newbie

Can you Improve on this or do you have a website or blog with C++ Tutorials.I would like to find more sites about C++ that are not 100% geeky and require you to read through 100′s of pages of documents before you can even know that you need a compiler to create programs in C++please share any tips you may have in the comments below.