cpp.codeblocks.1: Installing Code::Blocks - GNU/Linux

Learning Objectives:

  • Install and configure Code:Blocks and gcc on a Fedora Linux system.
  • Write, compile, and run a simple C++ vector program.



This video offers a brief introduction to C++ vectors. I actually walk you through building a C++ vector program from scratch after we install Code::Blocks.

cpp.codeblocks.1: Installing Code::Blocks -... by Djere University

The LibreOffice Impress-generated HTML slideshow for this lecture is here:
http://djere.com/lectures/node17lecture/node17.installing_codeblocks_lin...

***Here is the source code for the Vector program:***

djere.node17.cpp

// Djere.com Node 17 Example
// A simple C++ Program to Test Our Code::Blocks Installation.
// This program fills a vector with 10 double precision numbers input by the user.
// It then repeats the numbers entered back to the user.
// Written by Rex Djere of Djere.com

#include <iostream>
#include <vector>
using namespace std;

int main()
{
 vector<double> ourVector(0); // this creates an empty vector named "ourVector"
 double number = 0; // this variable stores the number input by the user
 int index; // this index stores our location in the vector

 // This "for" loop fills the vector with the numbers input by the user
 for (index=0; index < 10; index++)
  {
     cout << "Enter a number to input into the vector:" << endl;
     cin >> number;
     ourVector.push_back(number);
  }

 cout << "Here are the numbers that you entered into the vector:" << endl << endl;

 // This "for" loop repeats the vector elements back to the user
 for (index=0; index < 10; index++)
  {
     cout << "Position " << index << " = " << ourVector.at(index) << endl << endl;

  }

  cout << "Goodbye!" << endl;
  return 0;
}