GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ardacebi/cpp-examples: Simple and basic C++ examples for educational purposes.

BranchesTags
Open more actions menu

Latest commit

 

History

33 Commits
33 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bmi.cpp
bmi.cpp
 
 
helloworld.cpp
helloworld.cpp
 
 
space.cpp
space.cpp
 
 
temperature.cpp
temperature.cpp
 
 

Repository files navigation

C++ Examples

Simple and basic C++ examples for educational purposes.

Index

  • Building/Compiling
  • Contributing
  • Example Index

Building/Compiling

You can compile/build all these examples on your computer to change and try them out yourself.

Method 1: Using an IDE

Compiling C++ projects using your IDE is an easy way of editing and seeing it's result in a shorter time.

Visual Studio

After you've loaded (and perhaps edited) the project to Visual Studio, build it from the Build section.

Method 2: Terminal

Of course, you can follow the traditional way of building C++ projects from the terminal.

Linux

  1. Install GNU C/C++ compiler:

If you are using Fedora, Red Hat, CentOS, or Scientific Linux, use the following yum command to install GNU C/C++ compiler:

yum groupinstall 'Development Tools'

If you are using Debian or Ubuntu Linux, type the following apt-get command to install GNU C/C++ compiler:

$ sudo apt-get update

$ sudo apt-get install build-essential manpages-dev

  1. cd to the directory in which the C++ project is located
  2. Compile with g++ file.cpp -o file2
  3. Run with ./file

Mac

  1. Compile with g++ file.cpp
  2. Run with ./file

Windows

  1. Download MinGW from here or here.
  2. cd to the directory in which the C++ project is located (like: cd C:\Desktop...)
  3. Compile with g++ file.cpp -o file.exe
  4. Run the executable: file.exe.

Contributing

You can contribute your examples with a pull request.

  1. Prepare your example with the necessary code and a comment that indicates you're author on the top (see existing examples).
  2. Fork the repository
  3. Add your example(s)
  4. Open a pull request.

Your examples should be instructive and explanatory with comments. Make sure to explain important lines on your code (see existing examples). This is an important step as the main objective is to create an explanatory tutorial with all examples.

Example Index

  • BMI Calculator (file)
  • Hello World (file)
  • Space Traveler (file)
  • Temperature Converter (file)

BMI Calculator

Body mass index (BMI) is a value derived from the mass and height of a person. The BMI is defined as the body mass divided by the square of the body height.

This program calculates the BMI of a person by:

  1. Asking them their height in metres (m)
  2. Asking them their weight in kilograms (kg)
  3. Calculating their BMI with the formula weight / (height * height).

Hello World

This is a basic Hello World program.

Space Traveler

Someone is travelling from Earth to six potential other planets in our solar system. This program requests the person's weight on Earth, and then calculates their weight on the other planets.

The program does this by:

  1. Asking the person their weight on Earth
  2. Asking the person which planet they want to travel
  3. After receiving those information, it multiplies the person's weight with the gravitational force of that planet to calculate their weight on those planets.

Temperature Converter

This program converts Fahrenheit to Celsius and vice versa based on user selection.

The program does this by:

  1. Asking the user what they want to convert to and from (Fahrenheit to Celsius or Celsius to Fahrenheit)
  2. Asking the user to input the temperature value
  3. Outputting the final calculated value.

About

Simple and basic C++ examples for educational purposes.

Topics

basic-examplecppcpp-examplescpp-programmingeducationaleducational-materialsexamplesexamples-cppsimple-examplesimple-examples

Resources

Readme
Unlicense
Activity

Stars

3 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Sponsor this project

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.